-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Acknowledge+commit always issued in AckMode.MANUAL #3695
Comments
That is a bit strange logic:
What exactly the meaning of this structure? Something is off here and we will look into that next week or so as a team. Right now I definitely agree with you that for a normal I'll fix the problem for sync ack, even if we do that:
to have a single code block for everything. And we will think about Thank you and happy holidays! |
Thank you for your sample! So, when we don't use
So, we don't go to the |
…ack when sync Fixes: spring-projects#3695 Even if th `@KafkaHandler` method is `void` the `DelegatingInvocableHandler` returns an empty `InvocationResult`. That triggers a `MessagingMessageListenerAdapter.handleResult()` logic. On the `completableFutureResult.whenComplete()` we call `acknowledge()` which is not expected for `void` POJO methods. * Fix `MessagingMessageListenerAdapter` to check for `isAsyncReplies()` before calling `acknowledge()` This is a regression after spring-projects#3528
In what version(s) of Spring for Apache Kafka are you seeing this issue?
3.3.0
Worked fine with kafka 3.1.2
Describe the bug
MessagingMessageListenerAdapter issues acknoledge on successfull read handler, even if consumer ack mode is set to MANUAL, causing offsets to be commited
To Reproduce
We have a consumer that uses a partitionFinder to consume the same message on multiple pods without groupId, based on this example https://stackoverflow.com/questions/64022266/what-is-the-simplest-spring-kafka-kafkalistener-configuration-to-consume-all-re/
We can't set different groupIds to our consumers due to project restrictions and therefore use get-latest offset at the start and never- commit-offset strategy.
Config files
Here's our listener, we do not acknoledge the message. (Passing Acknoledgement object to receiverHandle doesn't change behaviour)
After upgrading to spring-kafka 3.3.0 we started receiveing the folllowing error
The error would be valid, if the message was acknoledged and we were trying to commit our offsets.
Brief comparison between 3.3.0 and spring-kafka 3.1.2 showed the following changes
Old:
KafkaMessageListenerContainer.buildCommits returns empty list, because this.offsets.entrySet()) is empty
No acknowledge is issued above the stack trace,
New:
KafkaMessageListenerContainer.buildCommits returns single record, because offsets where acknoledged
I suspect the root cause is within this block
MessagingMessageListenerAdapter
Expected behavior
KafkaMessageListenerContainer.buildCommits returning empty list, no attempt to commit offsets
A link to a GitHub repository with a minimal, reproducible, sample.
Thank you for any feedback or workaround
UPD: after some source code browsing, found an intersting block, setting acknolegde operation to use noAck-class
Unfortunatelly, this settings work only when KafkaListener annotation is set above method and annotated with NotNull annotation, not the component class. (IMAO, annotations above class and above method should work in the same way)
So, after the WA my source code looks like this
The text was updated successfully, but these errors were encountered: