-
Notifications
You must be signed in to change notification settings - Fork 641
Description
When you have a @RabbitListener
that returns a Mono
or CompletableFuture
, that is automatically recognized the the HandlerAdapter
, an the ListenerContainer
sets the AcknowledgeMode to MANUAL
automatically.
It would be great if the same behaviour is true for Kotlin suspend methods.
Current Behavior
When you start the Application, there is a warning:
[rabbit-simple-251] WARN o.s.a.r.l.a.MessagingMessageListenerAdapter - Container AcknowledgeMode must be MANUAL for a Mono<?> return type(or Kotlin suspend function); otherwise the container will ack the message immediately
And messages cannot be NACKed.
Context
Workaround: set the config property spring.rabbitmq.listener.simple.acknowledge-mode
to manual
(or spring.rabbitmq.listener.direct.acknowledge-mode
, dependend on what you are using.
Code that checks for async result:
Lines 50 to 56 in ed0a0b7
public HandlerAdapter(InvocableHandlerMethod invokerHandlerMethod) { | |
this.invokerHandlerMethod = invokerHandlerMethod; | |
this.delegatingHandler = null; | |
this.asyncReplies = (AbstractAdaptableMessageListener.monoPresent | |
&& MonoHandler.isMono(invokerHandlerMethod.getMethod().getReturnType())) | |
|| CompletableFuture.class.isAssignableFrom(invokerHandlerMethod.getMethod().getReturnType()); | |
} |