How to get topic list from kafka server in Java

后端 未结 6 545

I am using kafka 0.8 version and very much new to it.

I want to know the list of topics created in kafka server along with it\'s metadata.

6条回答
  •  长情又很酷
    2020-12-29 07:19

    A good place to start would be the sample shell scripts shipped with Kafka. In the /bin directory of the distribution there's some shell scripts you can use, one of which is ./kafka-topic-list.sh If you run that without specifying a topic, it will return all topics with their metadata. See: https://github.com/apache/kafka/blob/0.8/bin/kafka-list-topic.sh

    That shell script in turn runs: https://github.com/apache/kafka/blob/0.8/core/src/main/scala/kafka/admin/ListTopicCommand.scala

    The above are both references to the 0.8 Kafka version, so if you're using a different version (even a point difference), be sure to use the appropriate branch/tag on github

提交回复
热议问题