rabbitmq with spring boot amqp connection infinity错误@sendto fail

42fyovps  于 2021-07-13  发布在  Java
关注(0)|答案(1)|浏览(416)

我正在使用rabbitmq w/spring boot2.0.3。
目前我正在使用:

@Bean
    public SimpleRabbitListenerContainerFactory simpleRabbitListenerContainerFactory()
    {
        SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();

        factory.setConnectionFactory(cachingConnectionFactory);
...
        return factory;
    }

当我尝试的时候 rabbitTemplate.convertAndSend(exchange, routingKey, payload) 不存在交换,
错误显示一次,这是最好的。

2021-03-04 16:20:15.746 ERROR CachingConnectionFactory:1302 [AMQP Connection ip:5672] - Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'exchange' in vhost 'vhost', class-id=60, method-id=40)

但是,当我使用 @SendTo@RabbitListener ,例如。

@RabbitListener(queues = "test_mq_queue")
@SendTo("exchange/routingKey")

如果交换不存在,则显示错误无穷大。例如

2021-03-04 16:45:23.079 ERROR CachingConnectionFactory:1302 [AMQP Connection ip:5672] - Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'exchange' in vhost 'vhost', class-id=60, method-id=40)
2021-03-04 16:45:24.100 ERROR CachingConnectionFactory:1302 [AMQP Connection ip:5672] - Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'exchange' in vhost 'vhost', class-id=60, method-id=40)
2021-03-04 16:45:25.125 ERROR CachingConnectionFactory:1302 [AMQP Connection ip:5672] - Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'exchange' in vhost 'vhost', class-id=60, method-id=40)
2021-03-04 16:45:26.149 ERROR CachingConnectionFactory:1302 [AMQP Connection ip:5672] - Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'exchange' in vhost 'vhost', class-id=60, method-id=40)
2021-03-04 16:45:27.181 ERROR CachingConnectionFactory:1302 [AMQP Connection ip:5672] - Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'exchange' in vhost 'vhost', class-id=60, method-id=40)
...

我错过什么了吗?如果需要更多信息,请告诉我。

myss37ts

myss37ts1#

默认情况下,如果处理的任何部分失败,消息将被重新排队并重新传递(无限期)。这可以配置为拒绝和不重新排队。
但是,当发送失败并出现此错误时,代理将关闭通道,并重新请求和传递消息。斯普林没有机会干预以阻止重新交付。
您需要避免这种情况才能解决此问题。

相关问题