@@ -278,7 +278,19 @@ public void close()
278278 public void close (int closeCode , String closeMessage )
279279 throws IOException
280280 {
281- close (closeCode , closeMessage , true , null );
281+ close (closeCode , closeMessage , true , null , false );
282+ }
283+
284+ public void abort ()
285+ throws IOException
286+ {
287+ abort (AMQP .REPLY_SUCCESS , "OK" );
288+ }
289+
290+ public void abort (int closeCode , String closeMessage )
291+ throws IOException
292+ {
293+ close (closeCode , closeMessage , true , null , true );
282294 }
283295
284296 /**
@@ -289,7 +301,8 @@ public void close(int closeCode, String closeMessage)
289301 public void close (int closeCode ,
290302 String closeMessage ,
291303 boolean initiatedByApplication ,
292- Throwable cause )
304+ Throwable cause ,
305+ boolean abort )
293306 throws IOException
294307 {
295308 // First, notify all our dependents that we are shutting down.
@@ -306,29 +319,38 @@ public void close(int closeCode,
306319 }
307320
308321 BlockingRpcContinuation <AMQCommand > k = new SimpleBlockingRpcContinuation ();
309- // Synchronize the block below to avoid race conditions in case
310- // connnection wants to send Connection-CloseOK
311- synchronized (this ) {
312- processShutdownSignal (signal , !initiatedByApplication , true );
313- quiescingRpc (reason , k );
314- }
315-
322+ boolean notify = false ;
316323 try {
324+ // Synchronize the block below to avoid race conditions in case
325+ // connnection wants to send Connection-CloseOK
326+ synchronized (this ) {
327+ processShutdownSignal (signal , !initiatedByApplication , true );
328+ quiescingRpc (reason , k );
329+ }
330+
317331 // Now that we're in quiescing state, channel.close was sent and
318332 // we wait for the reply. We ignore the result. (It's always
319333 // close-ok.)
334+ notify = true ;
320335 k .getReply (-1 );
321336 } catch (TimeoutException ise ) {
322337 // Will never happen since we wait infinitely
338+ } catch (ShutdownSignalException sse ) {
339+ if (!abort )
340+ throw sse ;
341+ } catch (IOException ioe ) {
342+ if (!abort )
343+ throw ioe ;
323344 } finally {
324-
325- // Now we know everything's been cleaned up and there should
326- // be no more surprises arriving on the wire. Release the
327- // channel number, and dissociate this ChannelN instance from
328- // our connection so that any further frames inbound on this
329- // channel can be caught as the errors they are.
330- releaseChannelNumber ();
331- notifyListeners ();
345+ if (abort || notify ) {
346+ // Now we know everything's been cleaned up and there should
347+ // be no more surprises arriving on the wire. Release the
348+ // channel number, and dissociate this ChannelN instance from
349+ // our connection so that any further frames inbound on this
350+ // channel can be caught as the errors they are.
351+ releaseChannelNumber ();
352+ notifyListeners ();
353+ }
332354 }
333355 }
334356
0 commit comments