log.info("{} - Subscribing to topic test", id);
consumer.subscribe(Arrays.asList("test"));
- // tag::loop[]
while (running)
{
ConsumerRecords<String, String> records =
consumer.poll(Duration.ofSeconds(1));
- // Do something with the data...
- // end::loop[]
log.info("{} - Received {} messages", id, records.count());
for (ConsumerRecord<String, String> record : records)
{
record.value()
);
}
- // tag::loop[]
}
- // end::loop[]
}
catch(Exception e)
{