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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
- 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.