【问题标题】:How to acknowledge all successful messages with "Mono" handler?如何使用“Mono”处理程序确认所有成功的消息?
【发布时间】:2021-10-20 07:58:52
【问题描述】:

我正在使用spring amqp,我使用异步返回类型,例如Mono。我的处理程序之一:

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

当我使用这种方法时,我会收到下一个警告:

[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

我可以使用下一个approach 进行手动确认。但是我有一百个处理程序,因此,这种方法似乎不方便(我需要更改所有处理程序)。

我只想在成功执行后确认所有消息。 如何在不更改旧代码的情况下在一个地方为所有处理程序编写全局策略?

【问题讨论】:

    标签: spring rabbitmq project-reactor spring-amqp


    【解决方案1】:

    您不需要手动确认此类消息;当Mono 完成时,框架会处理它。

    警告只是告诉你容器没有正确配置这个返回类型。

    【讨论】:

    猜你喜欢
    • 2021-11-06
    • 2020-06-11
    • 2017-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-23
    • 2021-01-11
    • 2020-10-04
    相关资源
    最近更新 更多