简体   繁体   English

重试队列绑定到 RabbitMQ 交换

[英]Retry queue binding to RabbitMQ exchange

Using Spring-Boot with RabbitMQ I'm trying to create an exchange that can have n-number of queues, one for each of the microservices so each of them will get the same message.使用带有 RabbitMQ 的 Spring-Boot 我试图创建一个可以有 n 个队列的交换,每个微服务一个,这样每个微服务都会得到相同的消息。

Producer microservice has a Fanout Exchange defined.生产者微服务定义了一个扇出交换。 Each Consumer microservice creates a queue and attempts to connect it to the Producer exchange每个消费者微服务创建一个队列并尝试将其连接到生产者交换

When Producer is started first, exchange is created.当 Producer 首先启动时,就创建了 Exchange。 Starting Consumer microservices bind to the Producer exchange.启动消费者微服务绑定到生产者交换。 However in case when Consumer microservices are started first, they will not bind as there is nothing to bind to yet giving this log:但是,如果消费者微服务首先启动,它们将不会绑定,因为还没有什么可绑定的,但会给出以下日志:

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://guest@127.0.0.1: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

How can I configure Consumer microservices(or Producer) to try to bind the queues to the Producer exchange even if they were started before the exchange existed.我如何配置消费者微服务(或生产者)以尝试将队列绑定到生产者交换,即使它们在交换存在之前启动。

Another approach would be Producer creating the queues dynamically based on the starting Consumer microservices information, which then will listen on given queue.另一种方法是生产者根据起始消费者微服务信息动态创建队列,然后将侦听给定队列。 However the issue would still be there, if queue is not created fast enough or Consumer is created before Producer then the listener will throw an exception但是问题仍然存在,如果队列创建速度不够快或消费者在生产者之前创建,则侦听器将抛出异常

我们不能在您的消费者应用程序中指定一个绑定 bean 吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Spring Boot Rabbitmq中的运行时创建队列/交换/绑定/侦听器 - create queue/exchange/binding/listener at run time in spring boot rabbitmq RabbitMQ Exchange和队列不会自动创建 - RabbitMQ Exchange and Queue are not created automatically 有没有办法在 RabbitMQ 中明确地将队列绑定到默认交换? - Is there way to bind queue to default exchange explicitly in RabbitMQ? Spring rabbitmq发送到动态绑定交换 - Spring rabbitmq send to exchange with dynamic binding 为什么rabbitmq的队列绑定会自动更改? - Why rabbitmq's queue binding is auto changed? RabbitMQ多线程通道和队列绑定 - RabbitMQ multi-threaded channels and queue binding java Rabbitmq从队列或循环交换中解除绑定 - java rabbitmq unbinding from queue or a Round Robin Exchange 仅将消息发布到RabbitMQ Fanout交换(java)中的一个队列中 - Message only gets published to one queue in a RabbitMQ Fanout exchange (java) RabbitMQ + Spring集成:从队列绑定到主题交换的消息转换 - RabbitMQ + Spring Integration: Message conversion from queue bound to a topic exchange Apache Camel,RabbitMQ:在autodelete = true的交换上使用autodelete = false的队列 - Apache Camel, RabbitMQ : Consuming a queue that is autodelete=false on an exchange that is autodelete=true
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM