簡體   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