<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Jonathan,<div>There are some subtleties here. Comments in-line:<div><br><div><div>On 22 Oct 2013, at 17:07, Jonathan Halterman <<a href="mailto:jhalterman@gmail.com">jhalterman@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><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; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">if you're doing rapid basicPublish calls to a non-existent exchange. Eventually basicPublish fails with an AlreadyClosedException, but this often occurs before the Channel's ShutdownListener is called. So the client has no fair way of avoiding the AlreadyClosedException.</div></blockquote>Let'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'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><br></div><div><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; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">So from my perspective, there are a few things I'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; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 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; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 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>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><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; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 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>It depends on what you mean by 'already closed'. If the client knows it has closed, then yes, I agree with you. If it doesn'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><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; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 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>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><br></div><div><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-spacing: 0px; border-collapse: separate; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="font-size: 12px; ">Steve Powell </span><font class="Apple-style-span" face="Georgia" size="3"><span class="Apple-style-span" style="font-size: 11px; ">[</span></font><i style="font-style: normal; "><font class="Apple-style-span" face="Georgia" size="3"><span class="Apple-style-span" style="font-size: 11px; ">Cell</span></font></i><font class="Apple-style-span" face="Georgia" size="3"><span class="Apple-style-span" style="font-size: 11px; ">: +44-7815-838-558</span></font><font class="Apple-style-span" face="Georgia"><span class="Apple-style-span" style="font-size: 11px; ">] </span><span style="font-size: 10px; ">[</span></font><span style="font-size: 10px; "><a href="http://www.rabbitmq.com/">RabbitMQ</a>,<font face="Helvetica"><i> </i></font><a href="http://gopivotal.com/">Pivotal</a>]</span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><i style="font-size: 12px; line-height: 19.1875px; ">“L’enfer, c’est les autres.” </i><span style="background-color: rgb(255, 255, 255); font-size: 12px; line-height: 19.1875px; ">Sartre</span></div><div><span style="background-color: rgb(255, 255, 255); font-size: 12px; line-height: 19.1875px; "><br></span></div></span></div></span></div></span></div></div></div></div></div></div></div></div></body></html>