Spring Cloud Stream Rabbit MQ 扇出交换

Spring Cloud Stream Rabbit MQ fanout exchange

在我的应用程序中,我正在使用 spring 云流集成 Rabbit MQ。默认情况下 spring 云流将目标创建为 Rabbit MQ 中类型主题的交换。如何配置 spring 云流以创建扇出类型的交换?

  1. 您绝对应该从消费者端或 Broker 绑定您的队列。那不应该是 Spring Cloud Stream Binder 级别。对于您的用例,您可以将绑定键视为 #:

When a queue is bound with "#" (hash) binding key - it will receive all the messages, regardless of the routing key - like in fanout exchange.

https://www.rabbitmq.com/tutorials/tutorial-five-java.html

  1. 您仍然可以为您的消费者使用所需的扇出交换,但应该涉及相同的 Broker 绑定功能,以通过相同的 # 关键技巧将您的扇出交换绑定到此 SCSt 主题交换。