-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Async suspend function listener not automatically acknowledged? #3740
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
Milestone
Comments
This is a bug after #1189. |
artembilan
added a commit
to artembilan/spring-kafka
that referenced
this issue
Feb 13, 2025
… functions Fixes: spring-projects#3740 Issue link: spring-projects#3740 Even if Kotlin `suspend` functions are called properly, the acknowledgement is not called because this kind of method is not treated as an `asyncReplies` mode * Fix `HandlerAdapter` to check for `KotlinDetector.isSuspendingFunction()` in addition to `CompletableFuture` & `Mono` * Adjust `EnableKafkaKotlinCoroutinesTests.kt` to verify that `acknowledgement` has been called by the Framework **Auto-cherry-pick to `3.3.x` & `3.2.x`**
artembilan
added a commit
that referenced
this issue
Feb 13, 2025
Fixes: #3740 Issue link: #3740 Even if Kotlin `suspend` functions are called properly, the acknowledgement is not called because this kind of method is not treated as an `asyncReplies` mode * Fix `HandlerAdapter` to check for `KotlinDetector.isSuspendingFunction()` in addition to `CompletableFuture` & `Mono` * Adjust `EnableKafkaKotlinCoroutinesTests.kt` to verify that `acknowledgement` has been called by the Framework **Auto-cherry-pick to `3.2.x`** # Conflicts: # spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/HandlerAdapter.java
spring-builds
pushed a commit
that referenced
this issue
Feb 13, 2025
Fixes: #3740 Issue link: #3740 Even if Kotlin `suspend` functions are called properly, the acknowledgement is not called because this kind of method is not treated as an `asyncReplies` mode * Fix `HandlerAdapter` to check for `KotlinDetector.isSuspendingFunction()` in addition to `CompletableFuture` & `Mono` * Adjust `EnableKafkaKotlinCoroutinesTests.kt` to verify that `acknowledgement` has been called by the Framework # Conflicts: # spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/HandlerAdapter.java (cherry picked from commit 914cf62)
This was referenced Feb 13, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Discussed in #3739
Originally posted by rbraeunlich February 13, 2025
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
The text was updated successfully, but these errors were encountered: