簡體   English   中英

rabbitMQ 與 spring 啟動 amqp 連接無窮大錯誤時 @Sendto 失敗

[英]rabbitMQ with spring boot amqp connection infinity error when @Sendto fail

我正在使用 rabbitMQ w/Spring Boot 2.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)
...

我錯過了什么嗎? 如果需要更多信息,請告訴我。

默認情況下,如果處理的任何部分失敗,則將消息重新排隊並重新傳遞(無限期地)。 這可以配置為拒絕並且不重新排隊。

但是,當發送失敗並出現此錯誤時,通道會被代理關閉,消息會重新排隊並重新傳遞。 Spring 沒有機會干預以防止重新交付。

您需要避免這種情況才能解決此問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM