0
votes

I am going with manual offset commit on Kafka. Is there a way to get the list of offsets committed whenever I do consumer.commitOffsets(); P.S. I am using a high level consumer.

1

1 Answers

0
votes

Not sure what Kafka version or client (ie, language) you are using. Java high level consumer offers

KafkaConsumer#committed(TopicPartition partition);

to receive the latest committed offset for a partitions. Thus, you could call this after you did the commit.

https://kafka.apache.org/0100/javadoc/index.html?org/apache/kafka/clients/consumer/KafkaConsumer.html

If you want to know the offsets before you are doing the commit, you need to get the offset for each last message per partition of the last poll(). Thus, after poll() when processing your records, you need to get this information via

ConsumerRecord#offset()

https://kafka.apache.org/0100/javadoc/index.html?org/apache/kafka/clients/consumer/ConsumerRecord.html