Fix messages waiting for empty topic (#60)

This commit is contained in:
Anton Petrov 2020-06-15 13:12:56 +03:00 committed by GitHub
parent b60f2a357e
commit 5a0b23ed59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -68,12 +68,13 @@ public class ConsumingService {
assignPartitions(consumer);
seekOffsets(consumer);
int pollsCount = 0;
while (!sink.isCancelled() || ++pollsCount > MAX_POLLS_COUNT) {
while (!sink.isCancelled() && ++pollsCount < MAX_POLLS_COUNT) {
ConsumerRecords<Bytes, Bytes> records = consumer.poll(POLL_TIMEOUT_MS);
log.info("{} records polled", records.count());
records.iterator()
.forEachRemaining(sink::next);
}
sink.complete();
} catch (Exception e) {
log.error("Error occurred while consuming records", e);
throw new RuntimeException(e);