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 <chinchutec...@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 >