You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by chinchu chinchu <ch...@gmail.com> on 2019/01/22 21:14:23 UTC
Kafka Consumer Not Assigned Partitions
Hello,
I have subscribed to a kafka topic as below . I need to run some logic
only after the consumer has been assigned a partition .How ever
consumer.assignment() comes back as an empty set no matter how long I wait
. If I do not have the while loop and then do a consumer.poll() I do get
the records from the topic.Can any one tell me why this is happening ?
consumer.subscribe(topics);
consumer.
Set<TopicPartition> assigned=Collections.emptySet();
while(isAssigned)
{
assigned = consumer.assignment();
if(!assigned.isEmpty()) {
isAssigned= false;
}
}
Thanks,
Chinchu
Re: Kafka Consumer Not Assigned Partitions
Posted by chinchu chinchu <ch...@gmail.com>.
Thanks Matthias.
On Wed, Jan 23, 2019 at 10:55 AM Matthias J. Sax <ma...@confluent.io>
wrote:
> Calling `consumer.subscribe()` is a local call. Only when you call
> `consumer.poll()` the consumer will connect to the broker to get its
> assignment. Thus, it's save to call `poll()` directly.
>
> `assignment()` will return the assignment only after the first `poll()`
> call.
>
>
> -Matthias
>
> On 1/23/19 9:00 AM, chinchu chinchu wrote:
> > Hello,
> > I have subscribed to a kafka topic as below . I need to run some logic
> > only after the consumer has been assigned a partition .How ever
> > consumer.assignment() comes back as an empty set no matter how long I
> wait
> > . If I do not have the while loop and then do a consumer.poll() I do get
> > the records from the topic.Can any one tell me why this is happening ?
> >
> > consumer.subscribe(topics);
> > consumer.
> >
> > Set<TopicPartition> assigned=Collections.emptySet();
> > while(isAssigned)
> > {
> > assigned = consumer.assignment();
> > if(!assigned.isEmpty()) {
> > isAssigned= false;
> > }
> > }
> >
> > Thanks,
> >
> > On Tue, Jan 22, 2019 at 2:14 PM chinchu chinchu <chinchutechie@gmail.com
> >
> > wrote:
> >
> >> Hello,
> >> I have subscribed to a kafka topic as below . I need to run some logic
> >> only after the consumer has been assigned a partition .How ever
> >> consumer.assignment() comes back as an empty set no matter how long I
> wait
> >> . If I do not have the while loop and then do a consumer.poll() I do
> get
> >> the records from the topic.Can any one tell me why this is happening ?
> >>
> >> consumer.subscribe(topics);
> >> consumer.
> >>
> >> Set<TopicPartition> assigned=Collections.emptySet();
> >> while(isAssigned)
> >> {
> >> assigned = consumer.assignment();
> >> if(!assigned.isEmpty()) {
> >> isAssigned= false;
> >> }
> >> }
> >>
> >> Thanks,
> >> Chinchu
> >>
> >
>
>
Re: Kafka Consumer Not Assigned Partitions
Posted by "Matthias J. Sax" <ma...@confluent.io>.
Calling `consumer.subscribe()` is a local call. Only when you call
`consumer.poll()` the consumer will connect to the broker to get its
assignment. Thus, it's save to call `poll()` directly.
`assignment()` will return the assignment only after the first `poll()`
call.
-Matthias
On 1/23/19 9:00 AM, chinchu chinchu wrote:
> Hello,
> I have subscribed to a kafka topic as below . I need to run some logic
> only after the consumer has been assigned a partition .How ever
> consumer.assignment() comes back as an empty set no matter how long I wait
> . If I do not have the while loop and then do a consumer.poll() I do get
> the records from the topic.Can any one tell me why this is happening ?
>
> consumer.subscribe(topics);
> consumer.
>
> Set<TopicPartition> assigned=Collections.emptySet();
> while(isAssigned)
> {
> assigned = consumer.assignment();
> if(!assigned.isEmpty()) {
> isAssigned= false;
> }
> }
>
> Thanks,
>
> On Tue, Jan 22, 2019 at 2:14 PM chinchu chinchu <ch...@gmail.com>
> wrote:
>
>> Hello,
>> I have subscribed to a kafka topic as below . I need to run some logic
>> only after the consumer has been assigned a partition .How ever
>> consumer.assignment() comes back as an empty set no matter how long I wait
>> . If I do not have the while loop and then do a consumer.poll() I do get
>> the records from the topic.Can any one tell me why this is happening ?
>>
>> consumer.subscribe(topics);
>> consumer.
>>
>> Set<TopicPartition> assigned=Collections.emptySet();
>> while(isAssigned)
>> {
>> assigned = consumer.assignment();
>> if(!assigned.isEmpty()) {
>> isAssigned= false;
>> }
>> }
>>
>> Thanks,
>> Chinchu
>>
>
Re: Kafka Consumer Not Assigned Partitions
Posted by chinchu chinchu <ch...@gmail.com>.
Hello,
I have subscribed to a kafka topic as below . I need to run some logic
only after the consumer has been assigned a partition .How ever
consumer.assignment() comes back as an empty set no matter how long I wait
. If I do not have the while loop and then do a consumer.poll() I do get
the records from the topic.Can any one tell me why this is happening ?
consumer.subscribe(topics);
consumer.
Set<TopicPartition> assigned=Collections.emptySet();
while(isAssigned)
{
assigned = consumer.assignment();
if(!assigned.isEmpty()) {
isAssigned= false;
}
}
Thanks,
On Tue, Jan 22, 2019 at 2:14 PM chinchu chinchu <ch...@gmail.com>
wrote:
> Hello,
> I have subscribed to a kafka topic as below . I need to run some logic
> only after the consumer has been assigned a partition .How ever
> consumer.assignment() comes back as an empty set no matter how long I wait
> . If I do not have the while loop and then do a consumer.poll() I do get
> the records from the topic.Can any one tell me why this is happening ?
>
> consumer.subscribe(topics);
> consumer.
>
> Set<TopicPartition> assigned=Collections.emptySet();
> while(isAssigned)
> {
> assigned = consumer.assignment();
> if(!assigned.isEmpty()) {
> isAssigned= false;
> }
> }
>
> Thanks,
> Chinchu
>