<div dir="ltr"><div>Thanks for your input! Good to hear that option C is a viable approach. The Lyra project looks interesting, will keep an eye on it.<br><br></div>/Peter<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Fri, Nov 1, 2013 at 3:02 AM, Mike Hadlow <span dir="ltr"><<a href="mailto:mike@suteki.co.uk" target="_blank">mike@suteki.co.uk</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">Hi Peter,<div><br></div><div>My .NET client library, EasyNetQ (<a href="http://easynetq.com" target="_blank">http://easynetq.com</a>) does automatic reconnection. We use option C with a class called PersistentConnection. An internal in-memory event bus then distributes connection events to the rest of the library so consumers get notified when they need to re-consume. Works well.</div>
<div><br></div><div>Good luck,</div><div>Mike</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 1, 2013 at 4:13 AM, Jonathan Halterman <span dir="ltr"><<a href="mailto:jhalterman@gmail.com" target="_blank">jhalterman@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">Hi Peter,<div><br></div><div>Solution C is actually pretty reasonable. There's not much to gain from using multiple connections to the same server if you're trying to guard against network failures or cluster partitions. If one connection dies, they all likely will. Wrapping and recovering connections/channels works fine, and as Michael mentioned, you might also check out Lyra since it handles the various corner cases involved in recovering resources for you.</div>
<div><br></div><div>Cheers,</div><div>Jonathan</div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Thu, Oct 31, 2013 at 10:28 AM, Peter Moberg <span dir="ltr"><<a href="mailto:moberg.peter@gmail.com" target="_blank">moberg.peter@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><p style="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;word-spacing:0px">
Hi,<br></p><p style="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;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="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;word-spacing:0px">
Imagine this pseudo application:</p><pre style="max-height:600px;text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;width:auto;font-style:normal;background-color:rgb(238,238,238);font-weight:normal;padding:5px;vertical-align:baseline;line-height:18px;text-transform:none;font-size:14px;overflow:auto;margin:0px 0px 10px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;word-wrap:normal;border:0px 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 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">{</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> conn</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">;</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> start</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">()</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">{</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> factory </span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">=</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">();</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
factory</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">.</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">setUsername</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">(</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">);</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
factory</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">.</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">setPassword</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">(</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">);</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
factory</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">.</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">setHost</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">(</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">);</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
conn </span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">=</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> factory</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">.</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">newConnection</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">();</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">(</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">(</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">conn</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">.</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">createChannel</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">())).</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">start</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">();</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">}</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">}</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">{</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">(</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> channel</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">)</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">{</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">.</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">channel </span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">=</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> channel</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">;</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">}</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> run</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">()</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">{</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">(</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">)</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> </span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">{</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">...</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px"> consume incoming messages on the channel</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">...</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span 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 style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">}</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">}</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">
</span><span style="vertical-align:baseline;font-size:14px;background-color:transparent;margin:0px;border:0px none;padding:0px">}</span></code></pre><p style="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;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="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;word-spacing:0px">
Solution A)</p><p style="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;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="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;word-spacing:0px">
Pros: It works</p><p style="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;word-spacing:0px">
Cons:</p><ul style="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em 30px;list-style:disc outside none;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;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="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;word-spacing:0px">
Solution B)</p><p style="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;word-spacing:0px">
Have each consumer use the same connection and subscribe to its connection failure events.</p><p style="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;word-spacing:0px">
Pros: Less connections than in Solution A</p><p style="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;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="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;word-spacing:0px">
Solution C)</p><p style="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;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="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;word-spacing:0px">
Pros: It work - this is actually the solution we are using today.</p><p style="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;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="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;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="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;word-spacing:0px">
<br></p><p style="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;word-spacing:0px">
Thanks,</p><p style="text-indent:0px;letter-spacing:normal;text-align:left;font-variant:normal;font-style:normal;font-weight:normal;padding:0px;vertical-align:baseline;clear:both;line-height:18px;text-transform:none;font-size:14px;white-space:normal;margin:0px 0px 1em;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;border:0px none;word-spacing:0px">
Peter<br></p></div>
<br></div></div><div>_______________________________________________<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>
<br></div></blockquote></div><br></div>
<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>
<br></blockquote></div><br></div>
</div></div><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>
<br></blockquote></div><br></div>