For the latest stable version, please use Spring for Apache Kafka 3.3.0! |
Manually Committing Offsets
Normally, when using AckMode.MANUAL
or AckMode.MANUAL_IMMEDIATE
, the acknowledgments must be acknowledged in order, because Kafka does not maintain state for each record, only a committed offset for each group/partition.
Starting with version 2.8, you can now set the container property asyncAcks
, which allows the acknowledgments for records returned by the poll to be acknowledged in any order.
The listener container will defer the out-of-order commits until the missing acknowledgments are received.
The consumer will be paused (no new records delivered) until all the offsets for the previous poll have been committed.
While this feature allows applications to process records asynchronously, it should be understood that it increases the possibility of duplicate deliveries after a failure. |
When asyncAcks is activated, it is not possible to use nack() (negative acknowledgments) when Committing Offsets.
|