[rabbitmq-discuss] Handling Undelivered messages in rabbitmq

Prashant Yadav PRYD at mach.com
Thu Jan 6 11:49:05 GMT 2011


Hello Emile,

Thanks for the quick response.

I presume by "consumer registered on queue", you mean binding queue to
the QueuingConsumer in my case. I changed the basicPublish immediate
flag to true and changed the queue declaration and binding of my
consumer.
Still am not able to get any response on my Producer for undelivered
messages.
According to you " If you had 'immediate' set and there were no
consumers registered on any of the relevant queues then
handleBasicReturn would be called "
My set up has single queue where producer is publishing messages and
consumers listens on different queue( which effectively fulfills your
condition, isn't ? I even tried just publishing with no consumers
running, still handleBasicReturn does not get called. 

Regds
Prashant


-----Original Message-----
From: Emile Joubert [mailto:emile at rabbitmq.com] 
Sent: Thursday, January 06, 2011 4:29 PM
To: Prashant Yadav
Cc: rabbitmq-discuss at lists.rabbitmq.com
Subject: Re: [rabbitmq-discuss] Handling Undelivered messages in
rabbitmq

Hi Prashant,

On 06/01/11 09:15, Prashant Yadav wrote:

> *1)*Publish the messages with Mandatory and Immediate flag sent
> *channel.basicPublish 'exchange' ,'rKey',true,false, props,"Hello
> World".bytes*

The 'false' in that call should be 'true' if you want 'immediate' set.

> *2)*The consumer consumes even marked ( I have put numbers from 1..10
as
> marked value in header of each messages) and does not ACKS odd
numbered
> messages.**
>
> *3)*I have implemented setReturnListnere in the publisher to capture
> undelivered messages.**
>
> While am able to get the number of unack messages via Rabbmitmqctl
> list_queues messages_unacknowledged, somehow my handleBasicReturn
method
> does not gets called. Am in missing something.

In your case the 'mandatory' flag will cause handleBasicReturn to be 
called only if the message cannot be routed, i.e.  the message ends up 
in 0 queues. But your messages can be routed so handleBasicReturn won't 
be called.

If you had 'immediate' set and there were no consumers registered on any

of the relevant queues then handleBasicReturn would be called. But you 
do have consumers registered so handleBasicReturn won't be called.

You could make use of the 'redelivered' flag upon message delivery to 
check whether processing has already been attempted and act accordingly.

You could republish messages to success and failure queues after 
processing, depending on the outcome and depending on how you want to 
treat failed messages.

---

Of possible interest is the ability of the management and monitoring 
plugin to report the number of unacknowledged messages.
See http://www.rabbitmq.com/management.html .

You can also retrieve queue depth over AMQP in the queue declare-ok 
return value after passively declaring a queue.


Regards

Emile


More information about the rabbitmq-discuss mailing list