You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Alex Melville <am...@g.hmc.edu> on 2015/02/27 07:10:13 UTC

How Query Topic For Metadata

I am writing a custom producer that needs to know information about the
topic it's about to produce to. In particular it needs to know the number
of partitions on the topic. Is there some utility method that returns such
data? I am using scala v2.9.2 and kafka v8.2.0.


Alex

Re: How Query Topic For Metadata

Posted by Ewen Cheslack-Postava <ew...@confluent.io>.
You might want ZkUtils.getPartitionsForTopic. But beware that it's an
internal method that could potentially change or disappear in the future.

If you're just looking for protocol-level solutions, the metadata API has a
request that will return info about the number of partitions:
https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-MetadataAPI

On Thu, Feb 26, 2015 at 10:10 PM, Alex Melville <am...@g.hmc.edu> wrote:

> I am writing a custom producer that needs to know information about the
> topic it's about to produce to. In particular it needs to know the number
> of partitions on the topic. Is there some utility method that returns such
> data? I am using scala v2.9.2 and kafka v8.2.0.
>
>
> Alex
>



-- 
Thanks,
Ewen