Do not wait for a full batch if there's no messages in the topic (#77)

This commit is contained in:
Anton Petrov 2020-07-09 12:40:39 +03:00 committed by GitHub
parent 4ed5f2dd10
commit 5ad3f5ce79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -107,6 +107,9 @@ public class ConsumingService {
while (!sink.isCancelled() && ++pollsCount < MAX_POLLS_COUNT) { while (!sink.isCancelled() && ++pollsCount < MAX_POLLS_COUNT) {
ConsumerRecords<Bytes, Bytes> records = consumer.poll(POLL_TIMEOUT_MS); ConsumerRecords<Bytes, Bytes> records = consumer.poll(POLL_TIMEOUT_MS);
log.info("{} records polled", records.count()); log.info("{} records polled", records.count());
if (records.count() == 0) {
break;
}
records.iterator() records.iterator()
.forEachRemaining(sink::next); .forEachRemaining(sink::next);
} }