在运行时停止RabbitMq侦听器



我的bean/listeners是使用IntegrationFlows构建的

前任。

@Bean
IntegrationFlow registerDevices() {
return IntegrationFlows
.from(adapter)
.channel(channel)
.get();
}

有这样一种方法可以在发生某些事情后停止侦听程序,端点调用/事件

RabbitListenerEndpointRegistry不起作用,因为我没有使用@RabbitListener

有可能设置autostart up - false,但如何在运行时很好地操作它?

首先,在这里为您的问题选择标签时请小心。到目前为止,您关心的问题实际上属于Spring Integration,与Spring AMQP无关。尽管您是对的:生命周期控制实际上最终会从Spring AMQP中转移到ListenerContainer

无论如何:用于您的用例的最终用户API是Spring集成逻辑的一部分。

参见from()的第二个论点:

.from(adapter, e -> e.id("myAmqpAdapter"))

因此,让idyo能够在运行时到达您的AmqpInboundChannelAdapter(实现Lifecycle(并停止&需要的时候就开始吧。

查看更多文档:

https://docs.spring.io/spring-integration/docs/current/reference/html/dsl.html#java-dsl端点

这种模式也很好:

https://docs.spring.io/spring-integration/docs/current/reference/html/system-management.html#control-总线

最新更新