You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Kamal C <ka...@gmail.com> on 2016/03/16 12:58:04 UTC

How to assign all the partitions of a topic to consumer ?

Hi,

    I'm using the new consumer in assign mode. I would like to assign all
the partitions of a topic to the consumer.

For that, I need to know the number of partitions available in the topic.

*consumer.assign(List<TopicPartitions> partitions);*

How to programmatically get the number of partitions in a topic?

--Kamal

Re: How to assign all the partitions of a topic to consumer ?

Posted by Kamal C <ka...@gmail.com>.
Thanks Jason! It worked. I've missed it.


On 17-Mar-2016 2:00 AM, "Jason Gustafson" <ja...@confluent.io> wrote:

> Have you looked at partitionsFor()?
>
> -Jason
>
> On Wed, Mar 16, 2016 at 4:58 AM, Kamal C <ka...@gmail.com> wrote:
>
> > Hi,
> >
> >     I'm using the new consumer in assign mode. I would like to assign all
> > the partitions of a topic to the consumer.
> >
> > For that, I need to know the number of partitions available in the topic.
> >
> > *consumer.assign(List<TopicPartitions> partitions);*
> >
> > How to programmatically get the number of partitions in a topic?
> >
> > --Kamal
> >
>

Re: How to assign all the partitions of a topic to consumer ?

Posted by Jason Gustafson <ja...@confluent.io>.
Have you looked at partitionsFor()?

-Jason

On Wed, Mar 16, 2016 at 4:58 AM, Kamal C <ka...@gmail.com> wrote:

> Hi,
>
>     I'm using the new consumer in assign mode. I would like to assign all
> the partitions of a topic to the consumer.
>
> For that, I need to know the number of partitions available in the topic.
>
> *consumer.assign(List<TopicPartitions> partitions);*
>
> How to programmatically get the number of partitions in a topic?
>
> --Kamal
>