使用主题交换配置多个 queues,并使用路由键将消息特定 queue 定向到 spring 云流

Configuring multiple queues with a topic exchange and using routing key to direct the message specific queue with spring cloud streams

使用主题交换配置多个 queues 并使用路由键将消息特定 queue 定向到 spring 云流

我的要求是示例我在消费者端queues 和交换定义如下

spring.cloud.stream.bindings.inputA.destination=Common-Exchange
spring.cloud.stream.bindings.inputA.group=A-Queue

spring.cloud.stream.bindings.inputB.destination=Common-Exchange
spring.cloud.stream.bindings.inputB.group=B-Queue

当然我们可以使用一个 queue 并使用 headers 来引导不同类型的消息,但我需要知道连接到单个交换器的多个 queue 如何处理流。

参见Rabbit binder documentation

  • 在消费者端,设置 bindingRoutingKey 消费者绑定 属性。
  • 在生产者方面,routingKeyExpression 生产者绑定 属性(例如 headers['routingKey'] 并根据需要设置 header)。

另见 Using Existing Queues/Exchanges