[rabbitmq-discuss] How to handle poison messages (version 3.0.1)?

Jerry Kuch jerryk at rbcon.com
Thu Jan 17 23:22:51 GMT 2013

Hi, Sandeep:

I'm using RabbitMQ version 3.0.1 and trying to handle the case with poison
> messages.

I assume that by a "poison message" you mean a message that a consumer can
definitively determine is somehow bad and should never be considered for
processing again?

> In our code here, if there is a problem with processing the message, we
> nack the message with redeliver flag set to true. However, this causes the
> message to go back in the queue and in turn the consumer reads the same
> message again (and again in a loop). This causes my consumer to crash or go
> fishing in a loop.

If we're using the same definition of poison message you could basic.reject
the message, specifying requeue=false.  This will cause Rabbit to dispose
of the message and not bother you with it again.

> I do have an option in mind - we can check for the redelivered flag to be
> true and if its true more than 3 times for a given message, we can post
> this message to a poison queue and ack it in the main queue. It's do-able
> but I'm hoping there is some option directly from rabbitMQ. Thanks in
> advance.

Such a compromise solution seems only to make sense if the message itself
wasn't truly poisonous, but rather the consumer that dequeued it just
wasn't able to deal with it properly upon taking possession of it.  Of
course counting the number of times a given message has arrived with the
redelivered flag set to true would require you to coordinate this count
globally across all of your consumers if there were more than one and this
might be a hassle.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130117/5d8e177d/attachment.htm>

More information about the rabbitmq-discuss mailing list