[rabbitmq-discuss] fanout exchange that does not keep messages

Matthias Radestock matthias at lshift.net
Mon Jul 20 17:54:56 BST 2009


Brian Whitman wrote:
> Hmm... this is not working the way I expect. 
> If I do either Holger or Matthias's solution the write-only "logger"
> queue continues to grow but the listener queues do stay at 0:
> ~/rabbitmq-server/scripts# ./rabbitmqctl list_queues name mode messages
> messages_ready messages_unacknowledged durable
> Listing queues ...
> logger_2b02ca30-754b-11de-99c0-0023dfde57d8 mixed 0 0 0 false
> logger mixed 110 110 0 false
> What I would like to see here is that logger is always 0 messages. If
> there are listeners or not, I don't want the queue called "logger" to
> ever retain any messages. 
> For both "logger" (write only) and the random queue names (read only) I
> am doing
>     ch.exchange_declare(my_exchange, 'fanout', durable=False,
> auto_delete=False)
>     qname, n_msgs, n_consumers = ch.queue_declare(queue_name,
> durable=False, exclusive=False, auto_delete=True)

If you have declared logger_* and logger as auto_delete then they should
not show up in list_queues *unless*

- both of them currently have consumers

- both of them have never had any consumers

The former case is presumably correct behaviour for you, so I suspect
what you are seeing is an instance of the second behaviour. The question
then is: How did you end up with queues that have never had any
consumers? Generally the way to avoid that is to make the *consumers*
perform these three steps:

1) declare auto-delete (or exclusive, if there is only one consumer per
queue) queue
2) bind queue
3) consume from queue

Note that queue declaration and binding are idempotent.

PS: I see you are using a development branch of the server. That could
have bugs in that area, so please try to get things working first using
the 1.6.0 release.

More information about the rabbitmq-discuss mailing list