1
votes

Iv been working recently with spring cloud stream rabbitmq producers and consumers. Is there a convention to where the queue should be created?

Should the queue be created on the consumer application

OR

Should the queue be created on the producer application

Personally I setup the queue on the consumer side and the exchange on the producer side. Iv got some feed back in work that id doesn't really matter where you create the queue but I beg to differ.

If the queue was created in the consumer, every time a new application came you wouldn't have any code changes just bind the queue and routing key in the exchange.

It this correct?

1

1 Answers

2
votes

Typically, what you have is correct; usually producers don't know about queues, only exchanges and routing keys.

There is a mechanism to create the queue(s) on the producer side (via the requiredGroups property). It was added because, if you deploy the producer first, you could lose messages because Rabbit drops unroutable messages by default.

As long as you deploy your consuming apps before their producers, it's "better" to configure the queue on the consumer side.