Kafka Error vs Error Field within each TopicPartition in the confluent kafka python on_commit callback()

30 views Asked by At

I'm writing a kafka consumer using confluent-kafka in Python. I'm using the asynccommit API. The documentation for the on_commit callback says the following. I don't understand the different between the First error argument and the individual errors within each TopicPartition argument. Can someone show me an example of how to handle this callback?

  • on_commit(kafka.KafkaError, list(kafka.TopicPartition)) (Consumer): Callback used to indicate success or failure of asynchronous and automatic commit requests. This callback is served upon calling consumer.poll(). Is not triggered for synchronous commits. Callback arguments: KafkaError is the commit error, or None on success. list(TopicPartition) is the list of partitions with their committed offsets or per-partition errors.

What would the arguments look like if
- there was no error
- there were some errors
- all of them errored out

1

There are 1 answers

0
OneCricketeer On

there was no error

First param would be None, as well as all TopicPartition.error

there were some errors

Some TopicPartition.error would be None. Everything else would not.

all of them errored out

All errors would be not None