Async suspend function listener not automatically acknowledged? #3739
Unanswered
rbraeunlich
asked this question in
Q&A
Replies: 4 comments
-
@rbraeunlich, this may be a bug that we are not checking for the |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yes. That's a bug.
has to be fixed like:
Raising an issue from this discussion... |
Beta Was this translation helpful? Give feedback.
0 replies
-
Did you create an issue @artembilan ? |
Beta Was this translation helpful? Give feedback.
0 replies
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
Hi everyone,
I was wondering about an error in my application (not part of my question). While trying to simplyfy my code, e.g. by using a
suspend
function in my listener, which is now being supported, I tried to find out if I have to do theack
by myself. I checked the documentation and also found this earlier question: #3290This indicates that I don't have to do the
ack
myself. Nevertheless, when debugging my integration tests I could see that the first message never was acknowledged. When doing it myself, all tests pass.The critical part seems to be this line:
https://github.com/spring-projects/spring-kafka/blob/main/spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/MessagingMessageListenerAdapter.java#L553
My suspend function doesn't return anything and therefore the adapter doesn't do the ack for me. The documentation only states "return types include CompletableFuture, Mono and Kotlin suspend functions". Not that my suspend function has to return anything.
Additionally, if I was to return a
kotlinx.coroutines.Job
orkotlinx.coroutines.Deferred
the helper inorg.springframework.kafka.listener.adapter.AdapterUtils#isAsyncReply
wouldn't recognize them because it only checks forMono
andCompletableFuture
.So, I wonder if the documentation here needs to be more specific or if the code is wrong.
Cheers,
Ronny
Beta Was this translation helpful? Give feedback.
All reactions