Java, How to get number of messages in a topic in apache kafka Ask Question

Java, How to get number of messages in a topic in apache kafka Ask Question

I am using Apache Kafka for messaging. I have implemented the producer and consumer in Java. How can we get the number of messages in a particular topic?

ベストアンサー1

It is not java, but may be useful

./bin/kafka-run-class.sh kafka.tools.GetOffsetShell \
  --broker-list <broker>:<port> \
  --topic <topic-name> \
  | awk -F  ":" '{sum += $3} END {print sum}'

おすすめ記事