如何停止使用@RabbitListener接收消息 [英] How to stop consuming messages with @RabbitListener
本文介绍了如何停止使用@RabbitListener接收消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用MessageListenerAdapter处理消息时,可以调用SimpleMessageListenerContainer.stop()来停止队列中的消费.但是,当我更改为使用@RabbitListener进行监听之后,找不到类似的方法.我尝试了CachingConnectionFactory.stop()但没有用.有人可以帮忙吗?非常感谢.
When I use MessageListenerAdapter to handle message, I could call SimpleMessageListenerContainer.stop() to stop consume from the queue. But after I change to use @RabbitListener to listen, I can't find a method like this. I tried CachingConnectionFactory.stop() but doesn't work. Could anyone help? Thank you very much.
推荐答案
- 给
@RabbitListener
和id
. - 获取对通过自动装配等方法侦听端点终结点Bean .
- 在注册表上调用
stop()
将停止所有容器. - 调用
getListenerContainer(id).stop()
停止单个容器.
- Give the
@RabbitListener
anid
. - Get a reference to the listener endpoint registry bean by autowiring etc.
- Calling
stop()
on the registry will stop all containers. - Call
getListenerContainer(id).stop()
to stop an individual container.
这篇关于如何停止使用@RabbitListener接收消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文