[rabbitmq-discuss] How to not publish messages, if queue is full?

Ceri Storey ceri at lshift.net
Wed Jul 24 12:20:45 BST 2013


(15/07/13 15:14), sergey at openbridge.com wrote:
> Hi everybody,
>
> I tried to put a limit on the queue size using 'x-max-length', but the
> problem is Messages will be dropped or dead-lettered from the front of
> the queue to make room for new messages once the limit is reached.
>  
> What are the possible ways to not drop the messages? Ideally I would
> like to throw an Exception if queue is full.
>
> First I was thinking to check the queue size, and if it's full than
> stop. But for example if I have 5 producers and queue limit size is
> set to 10, and I already have 9 messages in the queue, than all 5
> producers will check the size, and publish their messages and 4
> messages will be lost.
>
> That's how I declare x-max-length':
>
> result = channel.queue_declare(queue='Test', arguments={
> 'x-max-length' : 10})
>
>
It might be worth trying to drop messages with a probability based on
how full the queue is, like in the Random Early Detection
<http://en.wikipedia.org/wiki/Random_early_detection> queue management
scheme. So, pulling numbers out of the air, with a max queue length of
100, and if you start dropping messages when the queue is 50% full, then
you might drop 20% of messages when the queue is 60% full, and 80% when
90% full. The probabilistic aspect means that you're less dependent on
timing of queue length reads.

I should probably point out that I've not tried this myself, so I'd
advise caution and lots of experimentation.
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://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/20130724/da3e89c0/attachment.htm>


More information about the rabbitmq-discuss mailing list