kafka get partition count for a topic

前端 未结 15 1140
萌比男神i
萌比男神i 2020-12-13 00:05

How can I get number of partitions for any kafka topic from the code. I have researched many links but none seem to work.

Mentioning a few:

http://grokbase.c

15条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 00:59

    @Sunil-patil answer stopped short of answering the count piece of it. You have to get the size of the List

    producer.partitionsFor("test").size()

    @vish4071 no point butting Sunil, you did not mention that you are using ConsumerConnector in the question.

提交回复
热议问题