ConsumerRecord
The object kafka-python yields for each record a consumer reads, with fields such as topic, partition, offset, key, value and headers.
In more detail
Keys and values arrive as bytes unless a deserializer is configured, so the course calls decode on them before printing. The course code names each one msg.
Example
print(msg.partition, msg.offset, msg.key.decode(), msg.value.decode())Related terms
- KafkaConsumer — The kafka-python class that reads records from Kafka topics, joins consumer groups and commits offsets.
- Kafka record — One entry in a Kafka topic, made of an optional key, a value, optional headers and a timestamp.
- record header — A key and bytes-value pair attached to a record outside its value, used for metadata such as content type or a trace ID.
Taught in
- Green Tests, Red Production — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- A Consumer In Python — Apache Kafka & Event Streaming
- Headers, Envelopes And Event Metadata — Apache Kafka & Event Streaming