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

后端 未结 17 1470
不思量自难忘°
不思量自难忘° 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:34

    Excerpts from Kafka docs

    Deprecations in 0.9.0.0

    The kafka-consumer-offset-checker.sh (kafka.tools.ConsumerOffsetChecker) has been deprecated. Going forward, please use kafka-consumer-groups.sh (kafka.admin.ConsumerGroupCommand) for this functionality.

    I am running Kafka broker with SSL enabled for both server and client. Below command I use

    kafka-consumer-groups.sh --bootstrap-server Broker_IP:Port --list --command-config /tmp/ssl_config kafka-consumer-groups.sh --bootstrap-server Broker_IP:Port --command-config /tmp/ssl_config --describe --group group_name_x

    where /tmp/ssl_config is as below

    security.protocol=SSL
    ssl.truststore.location=truststore_file_path.jks
    ssl.truststore.password=truststore_password
    ssl.keystore.location=keystore_file_path.jks
    ssl.keystore.password=keystore_password
    ssl.key.password=key_password
    

提交回复
热议问题