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

Michael Klishin mklishin at gopivotal.com
Wed Oct 30 21:16:31 GMT 2013


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



More information about the rabbitmq-discuss mailing list