[rabbitmq-discuss] Multicasting

Matthias Radestock matthias at lshift.net
Wed May 6 09:56:16 BST 2009


bradford cross wrote:
> BTW, I used the binding/routing key approach for this example.  What 
> would be different about the code if I were to use the fan out exchange?

Any set up of a direct exchange and bound queues can be simulated by a 
set of fanout exchanges. Say, for example, that you have the following 

- one direct exchange
- queue a bound to it with binding key foo
- queue b bound to it with binding keys foo and bar

with the publisher publishing messages to the direct exchange and using 
routing keys foo or bar.

then you could alternatively set up the following:

- two fanout exchanges, called x.foo and x.bar
- queue a bound to x.foo
- queue b bound to x.foo and x.bar

and change the publisher to publish to exchange x.foo or x.bar rather 
than setting a routing key.

The main difference between the two approaches is the way unroutable 
messages are handled. Publishing a message to a direct exchange with a 
routing key that matches no bindings is perfectly fine; the message will 
simply be swallowed (and if you have the mandatory or immediate flags 
set the publisher will receive a basic.return message, indicating that 
routing failed). By contrast, publishing a message to a non-existing 
exchange, e.g. x.baz, results in an error.

There are also differences in how one can control access; RabbitMQ's 
upcoming ACLs operate on per resource (exchange, queue) basis, which 
means the second approach gives you more fine-grained control.


More information about the rabbitmq-discuss mailing list