我有一个Spring Cloud Stream应用程序,使用RabbitMQ Binders 来消息消息(它不会产生任何消息) . application.yaml
文件如下所示:
spring:
cloud:
stream:
rabbit:
bindings:
x:
consumer:
bindingRoutingKey: x.z.#
queueNameGroupOnly: true
y:
consumer:
bindingRoutingKey: y.z.#
queueNameGroupOnly: true
bindings:
x:
binder: rabbit
group: q1
destination: x
y:
binder: rabbit
group: q2
destination: y
这将在RabbitMQ中创建两个队列:
-
q1
必须与路由键x.z.#
交换x
-
q2
必须与路由键y.z.#
交换y
我想创建一个消耗多个交换和路由密钥的单个队列 . 我知道我无法将交换从 application.yaml
绑定到多个路由密钥(请参阅this SO问题),因此我怀疑我无法将Spring Cloud Stream配置为使用多个目标(交换)进行单个绑定 .
所以我的问题是,我可以以编程方式声明,以便一个 binding
从多个交换消耗?如果这样做,是否需要在 application.yaml
文件中保留任何内容?
我该怎么办?
1 回答
您可以使用exchange-to-exchange绑定来满足此要求 .
然后使用与
#
绑定的z上的单个队列进行消耗 .您可以定义交换以在引导应用程序中交换绑定,如
@Bean
.