See https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol
Using metadata api one can get topic partitions and for each partition which broker is lead. Using offset api one can get partition size. Both apis are low level and to use them directly you would use SimpleConsumer. To achieve same you can also use new KafkaConsumer - instantiate one belonging to unique group, subscribe to topic(s), poll, seek to beggining, ask for position, then seek to end and ask for position. On Mon, Mar 14, 2016, 21:20 Grant Overby (groverby) <grove...@cisco.com> wrote: > What is the most direct way to get a message count per topic or per > partition? > > For context, this is to enable testing. We'd like to confirm with Kafka > that a certain number of messages have been written or that the number of > messages we processed is equal to the number received by Kafka. > [ > http://www.cisco.com/web/europe/images/email/signature/est2014/logo_06.png?ct=1398192119726 > ] > > Grant Overby > Software Engineer > Cisco.com<http://www.cisco.com/> > grove...@cisco.com<mailto:grove...@cisco.com> > Mobile: 865 724 4910 > > > > > > > [http://www.cisco.com/assets/swa/img/thinkbeforeyouprint.gif] Think > before you print. > > This email may contain confidential and privileged material for the sole > use of the intended recipient. Any review, use, distribution or disclosure > by others is strictly prohibited. If you are not the intended recipient (or > authorized to receive for the recipient), please contact the sender by > reply email and delete all copies of this message. > > Please click here< > http://www.cisco.com/web/about/doing_business/legal/cri/index.html> for > Company Registration Information. > > > > >