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

后端 未结 17 1498
不思量自难忘°
不思量自难忘° 2020-11-30 19:11

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 topic?

17条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 19:40

    It is not java, but may be useful

    ./bin/kafka-run-class.sh kafka.tools.GetOffsetShell 
      --broker-list :   
      --topic  --time -1 --offsets 1 
      | awk -F  ":" '{sum += $3} END {print sum}'
    

提交回复
热议问题