Spring Cloud Stream Rabbit MQ fanout exchange

1.9k views Asked by At

In my application I am Integrating Rabbit MQ using spring cloud stream. By default spring cloud streams creates the destination as a exchange of type topic in Rabbit MQ. How to configure spring cloud stream to create a exchange of type fanout ?

1

There are 1 answers

3
Artem Bilan On BEST ANSWER
  1. You definitely should bind your queue from the consumer side or Broker. That should not be Spring Cloud Stream Binder level. For your use case you can consider the binding key as a #:

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

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

  1. You still can use desired fanout exchange for your consumer, but the same Broker binding feature should be involved to bind your fanout exchange to this SCSt topic exchange via the same # key trick.