<div dir="ltr">Hey Steve,<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 23, 2013 at 3:24 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">Jonathan,<div>There are some subtleties here. Comments in-line:<div><br><div><div class="im">
<div>On 22 Oct 2013, at 17:07, Jonathan Halterman &lt;<a href="mailto:jhalterman@gmail.com" target="_blank">jhalterman@gmail.com</a>&gt; wrote:</div><br><blockquote type="cite"><div style="font-family:Georgia;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
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>
</blockquote></div>Let&#39;s get one thing out of the way first of all.</div><div><br></div><div><font face="American Typewriter">Basic.Publish</font> is an asynchronous call. Therefore, if the channel is known and open as far as the client is concerned, there is no good reason for the <font face="American Typewriter">Basic.Publish</font> to fail (or know anything about the exchange&#39;s existence) and no way for the client to prevent subsequent <font face="American Typewriter">Basic.Publish</font> calls until there are replies back from the server. �Nor is there any way to stop previously queued consumer actions on that channel from running. <font face="American Typewriter">Consumer</font>s will be driven (eventually) with a�<font face="American Typewriter">handleShutdownSignal()</font>�as their last action. Any channel <font face="American Typewriter">ShutdownListener</font> will also be driven with the <font face="American Typewriter">ShutdownSignalException</font>�passed to it, but asynchronously. Ordering of action and listener call is not enforced by the client.</div>
<div><br></div><div>If a subsequent action on a closed channel is executed, you will get an <font face="American Typewriter">AlreadyClosedException</font> (sometimes�ought this to be always?) and this is due to an application initiated action (!), and has a channel reference. �(It is represented as a hard error, which is probably wrong.)�</div>
<div><br></div><div>Given the channel reference you can get the <font face="American Typewriter">ShutdownSignalException</font> <i>which closed that channel</i> with <font face="American Typewriter">Channel.getCloseReason().</font></div>
<div>This also works on <font face="American Typewriter">Connection</font>s.</div></div></div></div></blockquote><div><br></div><div>Ah yes, thanks for this pointer.</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><div><br></div><div><div class="im"><blockquote type="cite"><div style="font-family:Georgia;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
So from my perspective, there are a few things I&#39;d prefer to see out of all this:</div><div style="font-family:Georgia;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<br></div><div style="font-family:Georgia;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
- 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></blockquote></div>On <font face="American Typewriter">Channel</font> method calls it does that already, but has <font face="American Typewriter">hardError</font> set to true, which is sometimes misleading.</div>
<div><div class="im"><br><blockquote type="cite"><div style="font-family:Georgia;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
- 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></blockquote></div>It depends on what you mean by &#39;already closed&#39;. If the client knows it has closed, then yes, I agree with you. If it doesn&#39;t (yet) know it has closed (as in the case for a little while after a publish to a non-existent exchange) then it may not be able to throw an exception (yet). �It may, though, because some actions are synchronous with server interaction, which means we can tell from the response if something went wrong.</div>
</div></div></div></blockquote><div><br></div><div>In the case of basicPublish to a non-existent queue, eventually the channel will be closed, but the first time the client learns that the channel has been closed might be when it receives an AlreadyClosedException. And that&#39;s fine to me, as long as it doesn&#39;t result in the connection being closed, which it doesn&#39;t right now.</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><div><div class="im"><br><blockquote type="cite"><div style="font-family:Georgia;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
- 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></blockquote></div>See above: given the object that has closed, you should be able to get the <font face="American Typewriter">ShutdownSignalException</font> and determine why it closed.</div>
</div><div class="im"><div><br></div><div><div><div style="word-wrap:break-word"><div style="word-wrap:break-word"><div style="word-wrap:break-word"><div style="word-wrap:break-word"><div style="word-wrap:break-word"><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-size:12px">Steve Powell �</span><font face="Georgia" size="3"><span style="font-size:11px">[</span></font><i style="font-style:normal"><font face="Georgia" size="3"><span style="font-size:11px">Cell</span></font></i><font face="Georgia" size="3"><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"><span style="font-size:11px">]�</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="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><div><span style="line-height:19.1875px;font-size:12px"><br>
</span></div></span></div></span></div></span></div></div></div></div></div></div></div></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></div>