[rabbitmq-discuss] Binding queues on a topic exchange

Matthias Radestock matthias at lshift.net
Mon Jul 2 20:25:34 BST 2007


Ben,

"Ben Hood" <0x6e6562 at gmail.com> writes:

> I was wondering the difference is when a topic listener:
>
> a) Declares a well known queue name within an exchange to consume
> from. It is assumed that a routing key has already been bound to this
> queue (e.g. by a producer or an admin).

Let me rephrase that slightly: You have declared a topic exchange and a
queue bound to that exchange with a particular pattern. Your consumers
all consume messages from that queue. Correct?

> b) Declares a privately named queue and binds a routing key to that
> queue that the consumer is interested in listening to.

Let me rephrase that slightly: You have declared a topic exchange (as
before). Each consumer creates a private queue that it binds to the
topic exchange with a particular pattern. Correct?

> My assumption would be that in scenario (a), each consumer gets
> notified using the same shared data whereas in (b) a copy of each
> message is enqueued in the buffer of the consumer's private queue,
> thus making this queue not really a pub/sub, but more really P2P.
>
> Is this assumption correct?

For a topic exchange, a message gets delivered to all queues that match
the message's routing key with their binding pattern.

When you have multiple consumers on one queue, every message gets
delivered to *one* of the consumers.

So, taking your above cases, in the first example every message with a
matching routing key will be delivered to *one* of the consumers, and in
the second case every message with a given routing key is delivered to
*all* queues that match the routing key with their pattern, and then in
turn to the consumer(s) hanging off those queues (one per queue in this
example).


Regards,


Matthias




More information about the rabbitmq-discuss mailing list