如何停止使用@RabbitListener接收消息 [英] How to stop consuming messages with @RabbitListener

查看:794
本文介绍了如何停止使用@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.

推荐答案

  1. @RabbitListenerid.
  2. 获取对通过自动装配等方法侦听端点终结点Bean .
  3. 在注册表上调用stop()将停止所有容器.
  4. 调用getListenerContainer(id).stop()停止单个容器.
  1. Give the @RabbitListener an id.
  2. Get a reference to the listener endpoint registry bean by autowiring etc.
  3. Calling stop() on the registry will stop all containers.
  4. Call getListenerContainer(id).stop() to stop an individual container.

这篇关于如何停止使用@RabbitListener接收消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆