<div dir="ltr"><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Hi,<br></p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
I'm interested in knowing how other people handle recovering from a faulty connection using the official RabbitMQ java client library. We are using it to connect our application servers to our RabbitMQ cluster and we have implemented a few different ways to recover from a connection failure, but non of them feel quite right.</p>
<p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Imagine this pseudo application:</p><pre class="" style="margin:0px 0px 10px;padding:5px;border:0px none;font-size:14px;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;color:rgb(0,0,0);font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px">
<code style="margin:0px;padding:0px;border:0px none;font-size:14px;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"><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">public</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">class</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">OurClassThatStartsConsumers</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">{</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">Connection</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> conn</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">;</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">public</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">void</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> start</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">{</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">ConnectionFactory</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> factory </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">=</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">new</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">ConnectionFactory</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">();</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
factory</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">setUsername</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">"someusername"</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">);</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
factory</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">setPassword</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">"somepassword"</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">);</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
factory</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">setHost</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">"somehost"</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">);</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
conn </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">=</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> factory</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">newConnection</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">();</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">new</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">Thread</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">new</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">Consumer</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">conn</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">createChannel</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">())).</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">start</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">();</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">}</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">}</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">class</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">Consumer1</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">implements</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">Runnable</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">{</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">public</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">Consumer1</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">Channel</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> channel</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">)</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">{</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">this</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">channel </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">=</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> channel</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">;</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">}</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">@Override</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">public</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">void</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> run</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">{</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">while</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">true</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">)</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">{</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">...</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)"> consume incoming messages on the channel</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">...</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:gray">// How do we handle that the connection dies?</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">}</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">}</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">}</span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
In the real world we have several hundreds of consumers. So what happens if the connection dies? In the above example Consumer1 can not recover, when the connection closes, the Channel also closes, a state from which we can not recover. So lets look at some ways to solve this:</p>
<p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Solution A)</p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Let every consumer have their own connection and register the events that triggers when the connection dies and then handle reconnecting.</p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Pros: It works</p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Cons:</p><ul style="margin:0px 0px 1em 30px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);list-style:disc outside none;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<li style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent">Since we have a lot of consumers, we probably do not want that many connections.</li><li style="margin:0px;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:transparent">
We might possible have a lot of duplicated code for reconnecting to rabbit and handle reconnecting</li></ul><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Solution B)</p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Have each consumer use the same connection and subscribe to its connection failure events.</p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Pros: Less connections than in Solution A</p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Cons: Since the connection is closed we need to reopen/replace it. The java client library doesn't seem to provide a way to reopen the connection, so we would have to replace it with a new connection and then somehow notify all the consumers about this new connection and they would have to recreate the channels and the consumers. Once again, a lot of logic that i don't want to see in the consumer ends up there.</p>
<p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Solution C)</p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Wrap Connection and Channel classes is classes that handle the re-connection logic, the consumer only needs to know about the WrappedChannel class. On a connection failure the WrappedConnection with deal with re-establishing the connection and once connected the WrappedConnection will automatically create new Channels and register consumers.</p>
<p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Pros: It work - this is actually the solution we are using today.</p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Cons: It feels like a hack, I think this is something that should be handled more elegantly by the underlying library.</p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Maybe there is a much better way? The API documentation does not talk that much about recovering from a faulty connection. Any input is appreciated :)</p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<br></p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Thanks,</p><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:14px;vertical-align:baseline;background-color:rgb(255,255,255);clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Peter<br></p></div>