...
Kafka Consumer : Single Consumer Partition Assignments
...
Kafka Consumer : Starting the Poll Loop
Info |
---|
Primary function of the Kafka Consumer = poll() |
Code Block | ||
---|---|---|
| ||
// 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();
} |