多个应用程序下的Spring Cloud Stream DLQ,生产者和消费者

时间:2019-05-30 10:08:19

标签: rabbitmq spring-cloud-stream

我说应用程序A的生产者具有以下配置,

生产者属性:

spring.cloud.stream.bindings.packageVersionUpdatesPublishChannel.destination=fabric-exchange
    spring.cloud.stream.bindings.packageVersionUpdatesPublishChannel.producer.requiredGroups=version-updates
    spring.cloud.stream.rabbit.bindings.packageVersionUpdatesPublishChannel.producer.exchangeType=direct
    spring.cloud.stream.rabbit.bindings.packageVersionUpdatesPublishChannel.producer.routingKeyExpression='package-version'
    spring.cloud.stream.rabbit.bindings.packageVersionUpdatesPublishChannel.producer.bindingRoutingKey=package-version

在另一个应用程序B中,我有一个相同队列的使用者,

#Consumer Properties:
spring.cloud.stream.bindings.packageVersionUpdatesConsumerChannel.destination=fabric-exchange
spring.cloud.stream.bindings.packageVersionUpdatesConsumerChannel.group=package-version-updates
spring.cloud.stream.bindings.packageVersionUpdatesConsumerChannel.consumer.max-attempts=1
spring.cloud.stream.rabbit.bindings.packageVersionUpdatesConsumerChannel.consumer.exchangeType=direct
spring.cloud.stream.rabbit.bindings.packageVersionUpdatesConsumerChannel.consumer.durableSubscription=true
spring.cloud.stream.rabbit.bindings.packageVersionUpdatesConsumerChannel.consumer.bindingRoutingKey=package-version
#DLQ
spring.cloud.stream.rabbit.bindings.packageVersionUpdatesConsumerChannel.consumer.autoBindDlq=true
spring.cloud.stream.rabbit.bindings.packageVersionUpdatesConsumerChannel.consumer.dlqDeadLetterExchange=
spring.cloud.stream.rabbit.bindings.packageVersionUpdatesConsumerChannel.consumer.dlq-ttl=30000
#Error Exchange Creation and Bind the Same to Error Queue
spring.cloud.stream.bindings.packageVersionUpdatesErrorPublishChannel.destination=fabric-error-exchange
spring.cloud.stream.bindings.packageVersionUpdatesErrorPublishChannel.producer.requiredGroups=package-version-updates-error
spring.cloud.stream.rabbit.bindings.packageVersionUpdatesErrorPublishChannel.producer.exchangeType=direct
spring.cloud.stream.rabbit.bindings.packageVersionUpdatesErrorPublishChannel.producer.routingKeyExpression='packageversionupdateserror'
spring.cloud.stream.rabbit.bindings.packageVersionUpdatesErrorPublishChannel.producer.bindingRoutingKey=packageversionupdateserror

现在说,例如,如果应用程序A首先启动,那么将创建队列版本更新,而不会与之关联任何死信队列。

现在,当应用程序B启动时,这是我遇到的异常,并且通道被关闭,我认为这是因为应用程序B试图使用不同的配置重新创建队列

vhost'/'中队列'fabric-exchange.version-updates'的等价arg'x-dead-letter-exchange':收到的类型为'longstr'的值'DLX',但当前为无

任何人都可以让我知道,我该如何解决呢?我的要求是在App A中创建一个队列,而App-A会简单地将消息生成到该队列中

而App-B会消耗相同的电量,我的要求是在X倍的时间内通过DLQ支持重试

1 个答案:

答案 0 :(得分:0)

required-groups只是在生产者启动时提供使用者队列的一种便利,以避免在生产者首先启动时丢失消息。

您必须在两侧使用相同的交换/队列/绑定配置。