@@ -55,6 +55,9 @@ public abstract class AMQChannel extends ShutdownNotifierComponent {
5555 /** The current outstanding RPC request, if any. (Could become a queue in future.) */
5656 public RpcContinuation _activeRpc = null ;
5757
58+ /** Whether transmission of content-bearing methods should be blocked */
59+ public boolean _blockContent = false ;
60+
5861 /**
5962 * Construct a channel on the given connection, with the given channel number.
6063 * @param connection the underlying connection for this channel
@@ -233,6 +236,8 @@ public void processShutdownSignal(ShutdownSignalException signal,
233236 ensureIsOpen (); // invariant: we should never be shut down more than once per instance
234237 if (isOpen ())
235238 _shutdownCause = signal ;
239+
240+ notifyAll ();
236241 }
237242 } finally {
238243 if (notifyRpc )
@@ -248,8 +253,7 @@ public void notifyOutstandingRpc(ShutdownSignalException signal) {
248253 }
249254
250255 public synchronized void transmit (Method m ) throws IOException {
251- ensureIsOpen ();
252- quiescingTransmit (m );
256+ transmit (new AMQCommand (m ));
253257 }
254258
255259 public synchronized void transmit (AMQCommand c ) throws IOException {
@@ -258,10 +262,22 @@ public synchronized void transmit(AMQCommand c) throws IOException {
258262 }
259263
260264 public synchronized void quiescingTransmit (Method m ) throws IOException {
261- new AMQCommand (m ). transmit ( this );
265+ quiescingTransmit ( new AMQCommand (m ));
262266 }
263267
264268 public synchronized void quiescingTransmit (AMQCommand c ) throws IOException {
269+ if (c .getMethod ().hasContent ()) {
270+ while (_blockContent ) {
271+ try {
272+ wait ();
273+ } catch (InterruptedException e ) {}
274+
275+ // This is to catch a situation when the thread wakes up during
276+ // shutdown. Currently, no command that has content is allowed
277+ // to send anything in a closing state.
278+ ensureIsOpen ();
279+ }
280+ }
265281 c .transmit (this );
266282 }
267283
0 commit comments