...
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 in a loop for
}
}finally{
myConsumer.close();
} |