@@ -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,7 @@ 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+ setBlockContent (true );
236240 }
237241 } finally {
238242 if (notifyRpc )
@@ -248,22 +252,34 @@ public void notifyOutstandingRpc(ShutdownSignalException signal) {
248252 }
249253
250254 public synchronized void transmit (Method m ) throws IOException {
251- ensureIsOpen ();
252- quiescingTransmit (m );
255+ transmit (new AMQCommand (m ));
253256 }
254257
255258 public synchronized void transmit (AMQCommand c ) throws IOException {
256259 ensureIsOpen ();
260+ if (c .getMethod ().hasContent ()) {
261+ while (_blockContent ) {
262+ try {
263+ wait ();
264+ } catch (InterruptedException e ) {}
265+ ensureIsOpen ();
266+ }
267+ }
257268 quiescingTransmit (c );
258269 }
259270
260271 public synchronized void quiescingTransmit (Method m ) throws IOException {
261- new AMQCommand (m ). transmit ( this );
272+ quiescingTransmit ( new AMQCommand (m ));
262273 }
263274
264275 public synchronized void quiescingTransmit (AMQCommand c ) throws IOException {
265276 c .transmit (this );
266277 }
278+
279+ public synchronized void setBlockContent (boolean active ) {
280+ _blockContent = !active ;
281+ notifyAll ();
282+ }
267283
268284 public AMQConnection getAMQConnection () {
269285 return _connection ;
0 commit comments