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