KafkaConsumerRunner implements an iterator over Kafka messages. This was a good try, but Kafka polling is just not really compatible with the iterator model. E.g. it can only work in auto-commit mode, that does not allow "at least once" semantics, and may result in data loss.
So KafkaConsumerRunner is replaced with two alternative methods:
Direct use of Kafka Consumer
Callback API
@Inject
KafkaConsumerFactory factory;
// using Kafka API
Consumer<byte[], byte[]> c = factory.binaryConsumer()
.autoCommit(false)
.cluster("X")
.topics("topic1")
.group("group1")
.createConsumer();
// using KafkaConsumerCallback lambda
KafkaPollingTracker<String, String> p = factory.charConsumer()
.autoCommit(false)
.cluster("X")
.topics("topic1")
.group("group1")
.consume((c, d) -> data.forEach(r -> System.out.println(r.value())));
Upgrade Notes
If you were using KafkaConsumerRunner, you will have to switch to consume(KafkaConsumerCallback,Duration). The callback is invoked on a batch of data after each poll.
KafkaConsumerRunner
implements an iterator over Kafka messages. This was a good try, but Kafka polling is just not really compatible with the iterator model. E.g. it can only work in auto-commit mode, that does not allow "at least once" semantics, and may result in data loss.So
KafkaConsumerRunner
is replaced with two alternative methods:Consumer
Upgrade Notes
If you were using
KafkaConsumerRunner
, you will have to switch toconsume(KafkaConsumerCallback,Duration)
. The callback is invoked on a batch of data after each poll.