kafka-python KafkaConsumer multiple partition commit offset

Viewed 3111

Is it possible at all to commit offsets to Kafka topic which have multiple partitions so offset1 can be commited to partition1, offset2 to p2 and so on?

EDIT:

Yes, it is possible:

consumer = KafkaConsumer()
topicpartitions = [TopicPartition('topicname', partitionId) for partitionId in consumer.partitions_for_topic('topicname')]

consumer.assign(topicpartitions)
for tp in topicpartitions:
    consumer.commit({tp: OffsetAndMetadata(1000, None)})

for msg in consumer:
    #do whatever
1 Answers
Related