[rabbitmq-discuss] auto-delete exchange kills connections on consumer close?

Keith Irwin keith at zentrope.com
Tue Dec 20 00:12:03 GMT 2011


A belated things for your notes on this topic. Sure enough, the problem was that when I closed down a consumer, the exchange got take down with it. I managed to get things working, so it's all good.



On Dec 7, 2011, at 3:47 AM, Emile Joubert wrote:

> Hi Keith,
> On 06/12/11 06:00, Keith Irwin wrote:
>> Folks--
>> I'm using RabbitMQ (2.7.0 all around + java with Clojure) to send small
>> little status messages around here and there. It works great for that.
>> Because I don't care if these messages get dropped if, say, RabbitMQ
>> goes down, or if some client messes up here or there, I want to keep
>> everything temporary. When all the clients are stopped, I'm thinking,
>> RabbitMQ should be back to its default state.
>> So, when I use exchangeDeclare, I set auto-delete for the exchange to
>> true. Here are my expectations:
>> - When there are no more clients consuming or publishing to that
>> particular exchange, it'll disappear.
> Your description applies better to queues than exchanges. When the last
> client consuming from an auto-delete *queue* unsubscribes, the queue
> auto-deletes.
> An auto-delete exchange self-destructs when the last binding is removed.
> (If you are using exchange-to-exchange bindings then the exchange must
> be the source.) The binding might be removed as the result of an
> auto-delete queue disappearing, which in turn might happen as the result
> of a consumer unsubscribing, but that is incidental.
> Remember that consumers don't consume from an exchange directly.
>> What ACTUALLY happens is that when the first user of that exchange is
>> closed (by calling close on a channel), the exchange is deleted, and all
>> other users of that exchange get disconnected.
> As described earlier, a subscriber that unsubscribes can cause a cascade
> of auto-deletions to occur that removes an exchange. Publishers that
> attempt to publish to an absent exchange will then fail. Is this what is
> happening?
>> Is this a bug?
> If my interpretation is correct then no.
>> Should you always set autoDelete to false if there is ever going to be
>> more than one client using an exchange? And isn't there always going to
>> be another client using that exchange given there's no point in using an
>> MQ system otherwise?
> Don't use auto-delete exchanges if you will have more than one publisher
> for that exchange. There are use-cases where an exchange has a single
> publisher.
> Also consider whether the default exchange is sufficient for your needs.
> -Emile

More information about the rabbitmq-discuss mailing list