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