[rabbitmq-discuss] possible rabbitmq bug

Valentin Bernard vbernard42 at gmail.com
Fri Aug 26 08:48:06 BST 2011


I have also run into this, but Ask Solem recently shed light on that
behavior on the mailing list:
"Note that auto_delete queues are not deleted until the last consumer
 stops consuming from it, and an auto_delete queue is *not*
 deleted if there have never been any consumers consuming from it."

Yet, that does not explain why your queue is still deleted when you're
closing the connection... or I'm missing something too?



On Aug 25, 6:56 pm, Chris Behrens <cbehr... at codestud.com> wrote:
> Hi,
> I've been working with various python modules (carrot, kombu.. all using the python amqplib underneath) and I have spotted what I think may be a bug with rabbit.  I'd love to hear if anyone else is run into this or if I'm just plain wrong.
> I've been creating code that will re-use rabbit connections (they're pooled) to avoid the unnecessary cost of closing and reopening connections all of the time.  I create a channel on which I declare an exchange/queue with auto_delete=True.  If I do absolutely nothing more with this channel, and then close the channel, rabbit continues to have an empty queue sitting around _until_ the connection is closed.  It seems that closing the channel should nuke the queue, but it doesn't.   (This is not a very good use case I realize, but it can happen if I have some error handling in between declaring the queue and consuming it which ends up closing the channel before consuming.)
> More of a problem is that this is also the behavior if I consume with methods that result in a basic_get amqp command (NOT a basic_consume command).  Ie, if I create a channel, declare a queue auto_delete=True, use _only_ basic_get() to consume the queue and then close the channel when the queue is empty, the queue is also NOT nuked in this scenario.  This causes a huge problem when re-using connections that have declared random queue names.  Every time a connection is pulled from the pool and used, I have a random queue name lying around...  _until_ the connection is closed.   Shouldn't closing the channel end up removing the empty queue, as there's no more consumer for it?
> NOTE:  This problem goes away once you call basic_consume(), instead.  Once you've called basic_cancel(), you can basic_cancel() it, and the queue goes away.  Alternatively, instead of calling basic_cancel(), I can just close the channel, and the queue will go away.  So, the workaround to my problem is to always use basic_consume() instead of basic_get() (which is more efficient, anyway).... BUT I still have this rare corner case described first above.  Ie, if I declare an auto_delete queue on a channel, and immediately close the channel... the queue is left around when it should be removed.
> The complete workaround is to close the connection to rabbit, but then that means I can't use a pool of connections and recycle them anymore, obviously.  I lose the efficiency gained by not having to close/reopen connections all of the time.
> Comments?
> Thanks,
> - Chris
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-disc... at lists.rabbitmq.comhttps://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

More information about the rabbitmq-discuss mailing list