<div dir="ltr">I&#39;ve tried that but it appear the block never get executed as I don&#39;t see the &quot;this is an error&quot;.<div><br></div><div><div>channel.confirmSelect();</div><div><br></div><div><span class="" style="white-space:pre">        </span>channel.addReturnListener(new ReturnListener()</div>
<div><span class="" style="white-space:pre">        </span>{</div><div><span class="" style="white-space:pre">                </span>public void handleReturn(int replyCode,</div><div><span class="" style="white-space:pre">                                                </span>String replyText, </div>
<div><span class="" style="white-space:pre">                                                </span>String exchange, </div><div><span class="" style="white-space:pre">                                                </span>String routingKey, </div><div><span class="" style="white-space:pre">                                                </span>AMQP.BasicProperties props, </div>
<div><span class="" style="white-space:pre">                                                </span>byte[] msgContent)</div><div><span class="" style="white-space:pre">                </span>throws IOException {</div><div><span class="" style="white-space:pre">                        throw new RuntimeException(&quot;this is an error&quot;);</span></div>
<div><span class="" style="white-space:pre">                        </span></div><div><span class="" style="white-space:pre">                </span>}</div><div><span class="" style="white-space:pre">        </span>});</div></div></div><div class="gmail_extra"><br>
<br><div class="gmail_quote">On Wed, Oct 30, 2013 at 4:51 PM, Michael Klishin <span dir="ltr">&lt;<a href="mailto:mklishin@gopivotal.com" target="_blank">mklishin@gopivotal.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
On 31 Oct 2013, at 00:42, cw storm &lt;<a href="mailto:cwstorm@gmail.com">cwstorm@gmail.com</a>&gt; wrote:<br>
<br>
&gt; I want to capture the basic.return information (replyCode, replyText) if my basisPublish fails.  I&#39;ve set the channel to confirm.select and set mandatory flag to true.  It&#39;s my understanding that if an invalid routing key is provided, the message wouldn&#39;t route anywhere and the message should return to the client since it fail to route to a queue.  I just don&#39;t understand how to implement that in the java code.<br>

<br>
</div>Publishing is asynchronous, so is returning of messages to the client.<br>
You need to register a handler for returned messages. This can be used in combination<br>
with publisher confirms, as necessary.<br>
<br>
See <a href="http://www.rabbitmq.com/api-guide.html" target="_blank">http://www.rabbitmq.com/api-guide.html</a>, “Handling unroutable messages”.<br>
<div class="HOEnZb"><div class="h5"><br>
MK<br>
<br>
Software Engineer, Pivotal/RabbitMQ<br>
<br>
<br>
_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</div></div></blockquote></div><br></div>