KafkaConsumer

The kafka-python class that reads records from Kafka topics, joins consumer groups and commits offsets.

In more detail

Iterating over a KafkaConsumer calls poll behind the scenes and yields one ConsumerRecord at a time. Settings such as group_id, auto_offset_reset, enable_auto_commit and consumer_timeout_ms control where it starts, when it saves progress and when it stops.

Example

for msg in KafkaConsumer('events', group_id='readers'): print(msg.offset)

Related terms

Taught in

References

Certification courses