赞
踩
@RabbitListener(id = "xxx"
, bindings = @QueueBinding(value = @Queue(value = "queueNameXXX", autoDelete="true/false")
, exchange = @Exchange(value="exchangeXXX")
, key = "routeKeyXXX")
// 关闭自动监听
, autoStartup = "false"
)
@Autowired private RabbitListenerEndpointRegistry rabbitListenerEndpointRegistry; @Autowired private CachingConnectionFactory cachingConnectionFactory; public void start(){ // 开启监听 rabbitListenerEndpointRegistry.start(); } public void stop(){ // 关闭监听 rabbitListenerEndpointRegistry.stop(); cachingConnectionFactory.resetConnection(); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。