Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BATCH vs MANUAL and ack vs commit

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

like image 906
Hayi Avatar asked Dec 17 '25 14:12

Hayi


1 Answers

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.

like image 168
Artem Bilan Avatar answered Dec 20 '25 11:12

Artem Bilan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!