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

Simon MacMullen simon at rabbitmq.com
Wed Oct 30 14:03:36 GMT 2013


On 30/10/13 13:58, cw storm wrote:
> This is my try/catch block code.  When I publish, it will also but
> success just as long the exchange name is correct.  Even if you provide
> and invalid routing key, it'll be success.  It doesn't goto the catch block.

Mandatory publish failing does not cause an exception to be thrown in 
the Java client.

You need to register a ReturnListener:

http://www.rabbitmq.com/releases/rabbitmq-java-client/v3.2.0/rabbitmq-java-client-javadoc-3.2.0/com/rabbitmq/client/Channel.html#addReturnListener(com.rabbitmq.client.ReturnListener)

Cheers, Simon

-- 
Simon MacMullen
RabbitMQ, Pivotal


More information about the rabbitmq-discuss mailing list