<div dir="ltr"><div class="" itemprop="description" style="margin:0px 5px 5px 0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;word-wrap:break-word;width:660px;line-height:17.804800033569336px;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif">
<p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">using java client QueueingConsumer I wrote the following code to assist consumer recovery</p><pre style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:inherit">while (true) {
try{
.. create connection
.. create channel & queue
while (true) {
final QueueingConsumer.Delivery delivery = consumer.nextDelivery();
....
} catch {
handleException()
}
}
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">And every time I restarted rabbit it survived cause it created the connection from start.<br>
Now, I understand I should be working with DefaultConsumer.<br>So I have this method</p><pre style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:inherit">public void handleDelivery(...) throws IOException {
}
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">and my problems are :</p><ol style="margin:0px 0px 1em 30px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;list-style-position:initial">
<li style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">I cant catch the exception inside and recreate the connection</li><li style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
This only recovers when the ack fails. What if it fails in another stage of the process? How should I recover these fails? </li><li style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
Thanks.</li></ol></div></div>