Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Kafka Consumer : Single Consumer Partition Assignments

...

Kafka Consumer : Starting the Poll Loop

Info

Primary function of the Kafka Consumer = poll()

Code Block
languagejava
// Set the topic subscription or partition assignments
myConsumer.subscribe(topics);
myConsumer.assign(partitions);

try{
  while(true){
    ConsumerRecords<String, String> records = myConsumer.poll(100);
    //add business logic if needed
  }
}finally{
  myConsumer.close();
}