[将Spring-Boot与RabbitMQ结合使用,我试图创建一个交换,该交换可以具有n个队列,每个微服务都有一个队列,因此每个微服务都会收到相同的消息。
生产者微服务已定义了扇出交换。每个消费者微服务都会创建一个队列,并尝试将其连接到生产者交换机。
首先启动Producer时,将创建交换。启动消费者微服务绑定到生产者交换。但是,如果首先启动Consumer微服务,它们将不会绑定,因为尚无任何绑定到此日志:
2020-01-13 22:24:49.640 INFO [,,,] 88649 --- [ main] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672] 2020-01-13 22:24:49.685 INFO [,,,] 88649 --- [ main] o.s.a.r.c.CachingConnectionFactory : Created new connection: rabbitConnectionFactory#7746ae18:0/SimpleConnection@428ea503 [delegate=amqp://[email protected]:5672/, localPort= 62282] 2020-01-13 22:24:49.726 ERROR [,,,] 88649 --- [ 127.0.0.1:5672] o.s.a.r.c.CachingConnectionFactory : Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'abc-exchange' in vhost '/', class-id=50, method-id=20) 2020-01-13 22:24:50.748 ERROR [,,,] 88649 --- [ 127.0.0.1:5672] o.s.a.r.c.CachingConnectionFactory : Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'abc-exchange' in vhost '/', class-id=50, method-id=20) 2020-01-13 22:24:52.754 ERROR [,,,] 88649 --- [ 127.0.0.1:5672] o.s.a.r.c.CachingConnectionFactory : Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'abc-exchange' in vhost '/', class-id=50, method-id=20) 2020-01-13 22:24:56.763 ERROR [,,,] 88649 --- [ 127.0.0.1:5672] o.s.a.r.c.CachingConnectionFactory : Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'abc-exchange' in vhost '/', class-id=50, method-id=20) 2020-01-13 22:25:01.794 ERROR [,,,] 88649 --- [ 127.0.0.1:5672] o.s.a.r.c.CachingConnectionFactory : Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'abc-exchange' in vhost '/', class-id=50, method-id=20) 2020-01-13 22:25:01.807 INFO [,,,] 88649 --- [ main] o.s.a.r.l.SimpleMessageListenerContainer : Broker not available; cannot force queue declarations during start: java.io.IOException 2020-01-13 22:25:01.859 DEBUG [,,,] 88649 --- [ main] .b.c.i.c.AppConfig$CustomHttpTraceFilter : Filter 'httpTraceFilter' configured for use
我如何配置使用者微服务(或生产者)以尝试将队列绑定到生产者交换,即使队列在交换存在之前就已启动。
另一种方法是生产者根据起始的消费者微服务信息动态创建队列,然后,这些信息将侦听给定的队列。但是,问题仍然存在,如果创建队列的速度不够快,或者在Producer之前创建了Consumer,那么侦听器将引发异常
[将Spring-Boot与RabbitMQ结合使用,我试图创建一个交换,该交换可以具有n个队列,每个微服务都有一个队列,因此每个微服务都会收到相同的消息。生产者微服务...
我们不能在您的消费者应用程序中指定绑定bean吗?