繁体   English   中英

Spring 云 stream 兔子:当兔子服务器不可用时创建队列

[英]Spring cloud stream rabbit : Queue creation when rabbit server unavailable

我在用着
春天云流:3.1.4
弹簧云流粘合剂兔子:3.1.4

我有一个配置了此处属性的消费者。 我的问题是当消费者在 rabbitmq 服务器可用之前启动时,我可以看到消费者重新启动,直到连接可用。 然而,DLX 和 DLQ 之间创建的绑定并不相同。

  • 如果 rabbitmq 在消费者启动时可用:DLQ 使用路由键“ worker.request.queue.name ”和“ worker.request.dlq.name ”绑定到 DLX
  • 如果消费者在重试后启动时 rabbitmq 不可用:DLQ 仅使用 routingKey ' worker.request.dlq.name ' 绑定到 DLX。

问题是我需要两个绑定。 任何人都可以帮助我理解我做错了什么?

谢谢。

# 1. consumer queue configuration to listen for worker requests
# Exchange name
spring.cloud.stream.bindings.listenvalidateprocesssend-in-0.destination=${worker.request.exchange.name}
# Queue name
spring.cloud.stream.bindings.listenvalidateprocesssend-in-0.group=${worker.request.queue.name}
# Force creation of queue if doesn't exists.
spring.cloud.stream.bindings.listenvalidateprocesssend-in-0.consumer.requiredGroups=${worker.request.queue.name}
# Disable retry of error messages
spring.cloud.stream.bindings.listenvalidateprocesssend-in-0.consumer.maxAttempts=1

# 2. producer : to send worker responses to manager
spring.cloud.stream.bindings.listenvalidateprocesssend-out-0.destination=${worker.response.exchange.name}
spring.cloud.stream.bindings.listenvalidateprocesssend-out-0.group=${worker.response.queue.name}
# Do not create associated queue. Queue is created by the manager which subscribe to the exchange
# spring.cloud.stream.bindings.listenvalidateprocesssend-out-0.producer.requiredGroups=${worker.response.queue.name}

###############################
# Rabbit binder configuration #
###############################

# 1. consumer queue configuration to listen for worker requests
# Allows naming created queues with only group property. Default is destination.group.
spring.cloud.stream.rabbit.bindings.listenvalidateprocesssend-in-0.consumer.queueNameGroupOnly=true
# enable transaction of consumed messages. NOTE : the index must not be present in the binding name !!!!!
spring.cloud.stream.rabbit.bindings.listenvalidateprocesssend-in.consumer.transacted=true
# Queue and Exchange for request can be created by manager.
spring.cloud.stream.rabbit.bindings.listenvalidateprocesssend-in-0.consumer.maxPriority=255
spring.cloud.stream.rabbit.bindings.listenvalidateprocesssend-in-0.consumer.auto-bind-dlq=true
spring.cloud.stream.rabbit.bindings.listenvalidateprocesssend-in-0.consumer.deadLetterQueueName=${worker.request.dlq.name}
spring.cloud.stream.rabbit.bindings.listenvalidateprocesssend-in-0.consumer.deadLetterExchange=${worker.request.dlx.name}
spring.cloud.stream.rabbit.bindings.listenvalidateprocesssend-in-0.consumer.deadLetterRoutingKey=${worker.request.dlq.name}
spring.cloud.stream.rabbit.bindings.listenvalidateprocesssend-in-0.consumer.deadLetterExchangeType=topic
spring.cloud.stream.rabbit.bindings.listenvalidateprocesssend-in-0.consumer.dlqMaxPriority=255

编辑1:

After looking into sprint cloud stream rabbit bidder code, i can see the issue at: https://github.com/spring-cloud/spring-cloud-stream-binder-rabbit/blob/97c6f79fff15d985434e24c6b48c85caa962a4e6/spring-cloud-stream-binder -rabbit-core/src/main/java/org/springframework/cloud/stream/binder/rabbit/provisioning/RabbitExchangeQueueProvisioner.java#L659

每个 Queue/Exhcnage/Binding 声明初始化一次,每次尝试后重试一次。 但是声明列表是带有字符串键的 bean 的 map。 如果在同一个队列上进行双重绑定,hte 键是相同的,因此只保存第一个声明。 见这里: https://github.com/spring-cloud/spring-cloud-stream-binder-rabbit/blob/97c6f79fff15d985434e24c6b48c85caa962a4e6/spring-cloud-stream-binder-rabbit-core/src/main/java/org/springframework /cloud/stream/binder/rabbit/provisioning/RabbitExchangeQueueProvisioner.java#L629

这是一个错误; 请在这里打开一个问题https://github.com/spring-cloud/spring-cloud-stream-binder-rabbit/issues

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM