[rabbitmq-discuss] Exchange and queue naming conventions
david at rabbitmq.com
Mon Jan 24 18:14:18 GMT 2011
Bill Moseley <moseley at hank.org> writes:
> Are there any good conventions to follow when naming queues, exchanges, and
> bindings? As I'm adding more queues I'm starting to think some type of
> naming convention would be very smart. Just curious what other's do.
I don't think there is any one right way. When choosing names for
queues, exchanges, and keys, the use of dotted paths is widespread. But
your questions are more about usage than naming.
> For now I'm only using a direct exchange type. When should I be declaring
> additional exchanges vs. using the same (or even the default)
It depends on your message exchange patterns.
Generally, you should arrange your application to take full advantage of
the facilities AMQP presents. If your application ends up dispatching
or filtering messages in a way that could be delegated to RabbitMQ, then
you should do.
Also, consider where you might later want to add new producers and
consumers - even if just for debugging purposes. The ability to easily
add additional parties into message exchanges is one of the major
advantages of a messaging-based approach as opposed to point-to-point
mechanisms such as web services.
> A pattern I'm seeing is I have an app-specific producer than sends a message
> to a generic consumer (used by multiple apps) but then that consumer sends a
> message to another app-specific consumer. What I'm doing is passing the
> return queue name in the reply_to attribute. I'm not passing in the
> exchange name -- so I'm just using the same exchange for every
For a request-response pattern, this seems fine.
One variation is to make the exchange a topic exchange rather than a
direct exchange. This allows you to intercept all replies with a
wildcard binding (e.g. for debugging).
> I also declare the exchange, queue, and binding in every component (the
> producer and both consumers). I assume that's typical as it allows starting
> the components in any order. Is that appropriate?
Yes, this kind of thing is perfectly normal with AMQP.
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.
> Finally, I have been naming queue and bindings with the same name. Is there
> a reason that should not be done?
By naming bindings, I assume you are referring to the binding key.
There's nothing wrong with what you describe, except that this sounds
very close to what the AMQP nameless exchange does implicitly. So
perhaps you could take advantage of that, and so avoid the need to
declare an exchange and explicitly bind your queues.
Staff Engineer, RabbitMQ
SpringSource, a division of VMware
More information about the rabbitmq-discuss