Batch Listener(AckMode.MANUAL_IMMEDIATE) acks message even if acknowledgment.acknowledge() is not invoked #3982
Replies: 3 comments
-
Hi @artembilan @sobychacko, Could anyone please help with above query? Thanks |
Beta Was this translation helpful? Give feedback.
-
When using You're seeing expected behavior here. When you don't explicitly call Imagine this: You have nine records in the partition. In your first batch, let's say you receive three records (offsets 0, 1, and 2). However, you only acknowledge the first one, meaning the committed offset is at 1. However, the next poll in the consumer loop will deliver the next three records (offsets 3, 4, and 5). After processing this, your committed offset will still be at offset 1. Now, let's say you restart your application. You will receive records from offset 1 onwards since that is your last committed offset. As long as you are in the same consumer loop, you will continue receiving new batch records regardless of ack and commit. If you want to explicitly redeliver records from a prior poll due to some issues, you either have to use To recap, you see the expected behavior and by design. |
Beta Was this translation helpful? Give feedback.
-
@HimanshuLakra, I clarified my answer above as there was some vagueness in my original answer. Please take a look. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
I have a query regarding working of MANUAL_IMMEDIATE mode with BatchAcknowledgingMessageListener.
In the onMessage function if I do not invoke acknowledgment.acknowledge() the messages are still getting acked, is this expected?
Spring Kafka: 3.3.0
enable.auto.commit = false
AckMode: AckMode.MANUAL_IMMEDIATE
Below is my onMessage function of
public class KafkaMessageBatchManualModeListener implements BatchAcknowledgingMessageListener<String, Object>
`@Override
public void onMessage(List<ConsumerRecord<String, Object>> data, Acknowledgment acknowledgment) {
My expectation is if I do not invoke acknowledgment.acknowledge(index) function (ref: else block or catch block case)
then my messages should get redelivered in next poll, but they get acked.
To stop that ack I have to explicitly use nack
`if(ackIndex != null){
`
Beta Was this translation helpful? Give feedback.
All reactions