-1

I am running consumer using KafkaMessageListenerContainer.I need to stop the consumer on the topic's last message.How can i identify particular message is the last message in the topic.

1 Answers1

0

You can get it with the following shell command (remove --partition parameter to get offsets for all topic's partitions):

./bin/kafka-run-class kafka.tools.GetOffsetShell --broker-list <host>:<port> --topic <topic-name> --partition <partition-number> --time -1

As you can see, this is using the GetOffsetShell [0] object that you may use to get the last message offset and compare it with record's offset.

[0] https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/tools/GetOffsetShell.scala

fvaleri
  • 638
  • 1
  • 4
  • 10