[rabbitmq-discuss] How to determine if my message was publish successfully

cistron cwstorm at gmail.com
Wed Oct 30 21:56:23 GMT 2013


Can you recommend a better approach so that when I publish a message I want confirmation from rabbit that it was either successful or not.  What I want is a flag of some sort from rabbit that one of the input parameters is invalid such as the routing key.

Sent from my iPhone

> On Oct 30, 2013, at 5:16 PM, Michael Klishin <mklishin at gopivotal.com> wrote:
> 
>> On 31 Oct 2013, at 01:12, Michael Klishin <mklishin at gopivotal.com> wrote:
>> 
>> You can do something like
>> 
>> Exception e;
>> ch.addReturnListener(
>> // initialize e here from message attributes 
>> );
>> ch.basicPublish(…);
>> ch.waitForConfirms();
>> 
>> if(e != null) {
>> throw e;
>> }
> 
> I should add that this code is race condition prone and should
> not be literally as is. It was only to demonstrate the basic idea.
> 
> The return listener will be racing with waitForConfirm even if
> Rabbit delivers basic.return before basic.nack.
> --
> MK
> 
> Software Engineer, Pivotal/RabbitMQ
> 
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss


More information about the rabbitmq-discuss mailing list