0
votes

In the documentation :

BATCH: Commit the offset when all the records returned by the poll() have been processed.

MANUAL: The message listener is responsible to acknowledge() the Acknowledgment. After that, the same semantics as BATCH are applied.

if the offset is committed when all the records returned by the poll() have been processed for both cases then I don't get the difference, can you give me a scenario when MANUAL ack mode is used differently ?

If I use MANUAL mode and I don't call acknowledge() within my KafkaListener would be the same as BATCH mode ? and if I call acknowledge() what would change ?

Maybe I don't get the difference between commit and acknowledge notions within spring kafka

1

1 Answers

2
votes

In the perfect world, when your application is always UP, you definitely don't need those commits at all. Just because Kafka Consumer keeps the track of offset internally between poll calls. There might be the case when you really don't need to commit on every single batch delivered to you. That's when that MANUAL comes to the rescue. With BATCH mode you don't have control and the framework perform it for you anyway. With MANUAL you may decide to commit now or later on, some where after a couple batches processed.

It is called acknowledge because we might not perform a commit immediately, but rather store it in-memory for subsequent poll cycle. The commit must be performed exactly on the Kafka consumer thread.