当前位置:   article > 正文

【RabbitMQ】手动开关监听_rabbitlistenerendpointregistry.start();

rabbitlistenerendpointregistry.start();

一、@RabbitListener关闭自动监听

@RabbitListener(id = "xxx"
        , bindings = @QueueBinding(value = @Queue(value = "queueNameXXX", autoDelete="true/false")
        , exchange = @Exchange(value="exchangeXXX")
        , key = "routeKeyXXX")
        // 关闭自动监听
        , autoStartup = "false"
)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

二、RabbitMQ手动开关监听

    @Autowired
    private RabbitListenerEndpointRegistry rabbitListenerEndpointRegistry;

    @Autowired
    private CachingConnectionFactory cachingConnectionFactory;

    public void start(){
        // 开启监听
        rabbitListenerEndpointRegistry.start();
    }

    public void stop(){
        // 关闭监听
        rabbitListenerEndpointRegistry.stop();
        cachingConnectionFactory.resetConnection();
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/513259
推荐阅读
相关标签
  

闽ICP备14008679号