使用带有 Spring Boot 2.0.3 版本的 Spring Cloud Bus 时,我们在日志中看到以下异常
2019-08-07 14:12:56.049 ERROR 29 --- [X8-dnzvoAQ-2339] o.s.a.r.l.SimpleMessageListenerContainer :Consumer received fatal=false exception on startup
org.springframework.amqp.rabbit.listener.QueuesNotAvailableException: Cannot prepare queue for listener. Either the queue doesn't exist or the broker will not allow us to use it.
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:620)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:996)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s):[springCloudBus.anonymous.gcUQP3LKQq6eX8-dnzvoAQ]
基于谷歌,我们看到了这张 JIRA 票
https://github.com/spring-projects/spring-amqp/issues/818
Spring cloud bus 应该重新创建这个匿名队列。看起来这个问题在最新版本的 spring AMQP 基于这张票
https://jira.spring.io/browse/AMQP-834
但我的问题是我们如何在不升级这个库的情况下解决这个问题?