[rabbitmq-discuss] Question about Queue Bind/Unbind

Tony Garnock-Jones tonyg at lshift.net
Fri Apr 9 05:56:00 BST 2010


Hi Alvaro,

Alvaro Videla wrote:
> So far so good, but when I stop the app and then I say that the queue
> "usa" must be bound by the "usa.weather" routing key, nothing
> happens. the binding is not changed.
> 
> Then I read the code of rabbit_exchange:add_binding/4 and it seems
> that it doesn't support overwriting the binding.

Queue.bind won't alter a binding, but it will add a new binding. It's
also idempotent, so two or more queue.binds with identical arguments
will act the same as just one.

So the following:

 - queue.declare('usa')
 - queue.bind(binding_key = 'usa.news', queue = 'usa')
 - queue.bind(binding_key = 'usa.weather', queue = 'usa')

will (should!) result in *two* bindings. The queue should then receive
messages published to the exchange with either usa.news or usa.weather.

You could also use 'usa.*', if you like, to pick up all USAish messages
with a single binding.

Tony




More information about the rabbitmq-discuss mailing list