I was going to make a separate email thread for this question but this thread's topic echoes what my own would have been.
How can I query a broker or zookeeper for the number of partitions in a given topic? I'm trying to write a custom partitioner that sends a message to every partition within a topic, and so I need to know the total number of partitions before I call Producer.send(). Alex On Thu, Feb 26, 2015 at 7:32 PM, tao xiao <xiaotao...@gmail.com> wrote: > Gaurav, > > You can get the partition number the message belongs to via > MessageAndMetadata.partition() > > On Fri, Feb 27, 2015 at 5:16 AM, Jun Rao <j...@confluent.io> wrote: > > > The partition api is exposed to the consumer in 0.8.2. > > > > Thanks, > > > > Jun > > > > On Thu, Feb 26, 2015 at 10:53 AM, Gaurav Agarwal <gaurav130...@gmail.com > > > > wrote: > > > > > After retrieving a kafka stream or kafka message how to get the > > > corresponding partition number to which it belongs ? I am using kafka > > > version 0.8.1. > > > More specifically kafka.consumer.KafkaStream and > > > kafka.message.MessageAndMetaData classes, does not provide API to > > retrieve > > > partition number. Are there any other API's to get the partition > number? > > > > > > IF there are multiple partitions of a topic ,Do i need to declare from > > java > > > code how many partitions the topic contains or i can leave it topic > > > Kafkastream will take the partition information from kafka broker at > > > runtime.? > > > > > > > > > -- > Regards, > Tao >