<div dir="ltr">Comments below:<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Oct 22, 2013 at 7:46 AM, Steve Powell <span dir="ltr">&lt;<a href="mailto:steve@rabbitmq.com" target="_blank">steve@rabbitmq.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 style="word-wrap:break-word"><div><div>On 22 Oct 2013, at 11:42, Steve Powell &lt;<a href="mailto:steve@rabbitmq.com" target="_blank">steve@rabbitmq.com</a>&gt; wrote:</div>

<br><blockquote type="cite">Issuing a &#39;real work&#39; call after closing the channel, like�<font face="American Typewriter">channel.basicConsume()</font>, throws an�<font face="American Typewriter">AlreadyClosedException</font>, claiming that the connection is closed, but�<font face="American Typewriter">conn.isOpen()</font>�still returns true.</blockquote>

<div><br></div></div><div>Well, it appears that the <font face="American Typewriter">AlreadyClosedException</font> produces the &quot;clean connection shutdown&quot; string when it is a hard error (which is correct). It is called by the (internal) &#39;<font face="American Typewriter">channel.ensureIsOpen()</font>&#39; method (typically, if we are about to communicate across the channel). �But the <font face="American Typewriter">reference</font> in the exception is then to a <font face="American Typewriter">Channel</font>, </div>
</div></blockquote><div><br></div><div>This is the workaround I&#39;ve been using to determine if a Channel was closed versus a Connection - by looking at what type the reference is.</div><div>�</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>and although the exception implies that the connection has been closed, it hasn&#39;t. �This appears to contradict the hard error flag: which is supposed to mean the <i>connection</i> is closed.</div>

<div><br></div><div>I guess this means that the bug is <i>the connection isn&#39;t closed by the application initiated call to a closed channel.</i>��</div><div><br></div><div>You could argue this particular channel error doesn&#39;t violate the protocol, so there is no reason to suppose that the connection would (or should) be closed, so it shouldn&#39;t be a hard error. �[The code comments imply that <font face="American Typewriter">hardError==true</font> implies that <font face="American Typewriter">getReference()</font> returns a <font face="American Typewriter">Connection</font> object, which is actually <i>not</i> true anyway.]</div>

<div><br></div><div>As this thread stated right at the beginning (see subject), there is no provision in the code for issuing an <font face="American Typewriter">AlreadyClosedException</font> without it being a hard error. �If we could do this, the meaning of hardError would be preserved.</div>

<div><br></div><div>As in the case of referring to a consumer that the client has no record of, the client code can often determine if the channel is already closed, and <i>not</i>�risk any protocol violations before throwing the exception. �In these cases, it ought not to be a hard error: the connection can remain unaffected.</div>

</div></blockquote><div><br></div><div>That would be ideal, if an AlreadyClosedException due to an invocation against a closed Channel did not result in a Connection closure. The reason is (as we&#39;ve been discussing in a separate thread: Channel.basicPublish to a non-existent exchange...) sometimes the client receives an AlreadyClosedException *before* they are ever notified that the Channel was closed. This happens if you&#39;re doing rapid basicPublish calls to a non-existent exchange. Eventually basicPublish fails with an AlreadyClosedException, but this often occurs before the Channel&#39;s ShutdownListener is called. So the client has no fair way of avoiding the AlreadyClosedException.</div>
<div><br></div><div>So from my perspective, there are a few things I&#39;d prefer to see out of all this:</div><div><br></div><div>- That AlreadyClosedExceptions be allowed to represent channels that were already closed (as seems to be the case with the reference being set to a Channel).</div>
<div>- That an invocation against a Channel that has already been closed does not result in the Connection being closed (as seems to be the case).</div><div>- That AlreadyClosedExceptions include the Method that originally cased the closure as the shutdown reason (if any), such as 404. This would allow me to determine why a basicPublish fails.</div>
<div><br></div><div>Cheers,</div><div>Jonathan</div><div>�</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>
<div><br></div><div>
<div style="line-height:normal;text-indent:0px;letter-spacing:normal;text-align:-webkit-auto;font-variant:normal;text-transform:none;white-space:normal;word-wrap:break-word;word-spacing:0px"><div style="line-height:normal;text-indent:0px;letter-spacing:normal;text-align:-webkit-auto;font-variant:normal;text-transform:none;white-space:normal;word-wrap:break-word;word-spacing:0px">

<div style="line-height:normal;text-indent:0px;letter-spacing:normal;text-align:-webkit-auto;font-variant:normal;text-transform:none;white-space:normal;word-wrap:break-word;word-spacing:0px"><div style="line-height:normal;text-indent:0px;letter-spacing:normal;text-align:-webkit-auto;font-variant:normal;text-transform:none;white-space:normal;word-wrap:break-word;word-spacing:0px">

<div style="line-height:normal;text-indent:0px;letter-spacing:normal;text-align:-webkit-auto;font-variant:normal;text-transform:none;white-space:normal;word-wrap:break-word;word-spacing:0px"><span style="border-collapse:separate;border-spacing:0px"><div style="word-wrap:break-word">

<span style="border-collapse:separate;border-spacing:0px"><div style="word-wrap:break-word"><span style="border-spacing:0px;border-collapse:separate"><div style="word-wrap:break-word"><span style="font-family:Georgia;font-size:12px;font-weight:normal;font-style:normal">Steve Powell �</span><font face="Georgia" size="3" style="font-family:Georgia;font-size:medium;font-weight:normal;font-style:normal"><span style="font-size:11px">[</span></font><i style="font-family:Georgia;font-size:medium;font-weight:normal;font-style:normal"><font face="Georgia" size="3"><span style="font-size:11px">Cell</span></font></i><font face="Georgia" size="3" style="font-family:Georgia;font-size:medium;font-weight:normal;font-style:normal"><span style="font-size:11px">: <a href="tel:%2B44-7815-838-558" value="+447815838558" target="_blank">+44-7815-838-558</a></span></font><font face="Georgia" style="font-family:Georgia;font-weight:normal;font-style:normal"><span style="font-size:11px">]<span>�</span></span><span style="font-size:10px">[</span></font><span style="font-size:10px"><a href="http://www.rabbitmq.com/" target="_blank">RabbitMQ</a>,<font face="Helvetica"><i>�</i></font><a href="http://gopivotal.com/" target="_blank">Pivotal</a>]</span></div>

<div style="font-family:Georgia;font-size:medium;font-weight:normal;font-style:normal;word-wrap:break-word"><i style="font-size:12px;line-height:19.1875px">�L�enfer, c�est les autres.��</i><span style="line-height:19.1875px;font-size:12px">Sartre</span></div>

</span></div></span></div></span></div></div></div></div></div></div></div></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>