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

Brian Whitman brian at echonest.com
Mon Jul 20 17:51:58 BST 2009


Ah, if I do both
    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)
and send the message as immediate

    def message(self, message):
        self.ch.basic_publish(
            amqp.Message(pickle.dumps(message)),
            my_exchange, "logger", immediate=True
        )

Then it works the way I expect.




On Mon, Jul 20, 2009 at 12:36 PM, Brian Whitman <brian at echonest.com> 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)
>
>
>
>
>
>
>
> On Mon, Jul 20, 2009 at 12:20 PM, Matthias Radestock <matthias at lshift.net>wrote:
>
>> Brian, Holger,
>>
>> Holger Hoffstätte wrote:
>> > Brian Whitman wrote:
>> >> I am concerned about this because over the weekend the broker crashed
>> >> (not sure why yet, but I assume it had something to do with probably
>> >> ~50m messages sitting in the exchange.) How can I have messages be
>> >> completely transient?
>> >
>> > This is done with the "immediate" flag for a message; if there is no
>> > recipient, the message will be dropped.
>>
>> Actually, generally a better solution to the problem is to ensure that
>> the queues do not outlive the consumers - by either marking them
>> exclusive (if you only have one consumer per queue) or auto-delete.
>>
>> That way messages do really get dropped silently when there are no
>> consumers. By contrast, when setting 'immediate' the server will send a
>> basic.return to the producer.
>>
>> And buffering can still take place to deal with temporarily
>> backlogged/slow consumers. By contrast, with 'immediate' the messages
>> will get dropped when the consumers are busy (not just when they are not
>> present).
>>
>>
>> Regards,
>>
>> Matthias.
>>
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20090720/8c0cbe64/attachment.htm 


More information about the rabbitmq-discuss mailing list