0

I'm working with spring amqp and I use asynchronous return types like Mono. The one of my handlers:

    @RabbitHandler
    public Mono<Response<PopularityReport>> popularityReport(PopularityReportCommand command) {
        return Mono.just(foo);
    }

When I use such an approach I get the next warning:

[ntContainer#0-1] .a.r.l.a.MessagingMessageListenerAdapter : Container AcknowledgeMode must be MANUAL for a Mono<?> return type; otherwise the container will ack the message immediately

I could use the next approach for manual acknowledgments. But I have a hundred handlers and for this reason, that approach seems me like inconvenient (I need to change all handlers).

I wanna acknowledge all messages only after successful execution. How could I write a global strategy for all my handlers in one place without changing the old code?

Volodya Lombrozo
  • 2,325
  • 2
  • 16
  • 34

1 Answers1

1

You don't need to manually ack such messages; the framework takes care of it when the Mono completes.

The warning is just to tell you that the container is not configured properly for this return type.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • yes, it seems so. Can you please tell me where I can see it (in the code)? – Volodya Lombrozo Aug 23 '21 at 06:23
  • 1
    https://github.com/spring-projects/spring-amqp/blob/bd088731b08ceb7ca90543e18b19cbf70a21c6c8/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/adapter/AbstractAdaptableMessageListener.java#L396-L399 – Gary Russell Aug 23 '21 at 12:29