I'm starting out with RabbitMQ and I have an architectural dilemma. I was about to build message consumer classes which declare the queues and exchanges they consume from and write to. In order to avoid mismatches in queue configuration options and names between multiple consumers and producers, I created a "repository" class which holds the queue names and options.
And then it struck me... Instead of having each consumer class contain the list of the queues it uses, why not have a global configChannel(Channel) static method which would declare ALL queues and exchanges for every channel I create? This way, I wouldn't have to worry about the order in which they're declared. Is there a downside? If not, why isn't this kind of approach recommended in the documentation (as far as I could see)?
edit
I found some more info here:
http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2013-June/027880.html
I think the expectation is that producers and consumers should declare the things that they directly interact with."
https://groups.google.com/forum/#!topic/rabbitmq-discuss/Jp49IRe693o
Typically, both the producers and consumers will declare the exchanges of interest. But only consumers will declare and bind the queues, because they know which messages they wish to receive.
If I understand correctly, to avoid messages getting black-holed (queue not declared yet) when the producer only declares the exchange it publishes to, some synchronization is necessary to make sure the consumer(s) is(are) started first and declares its(their) queue. Why bother with the potential trouble and not declare queues up front for every producer and consumer? I imagine there are applications which require dynamically created queues so that's another story. My argument pertains to the static or permanent application message queues when they exist.