@@ -91,8 +91,6 @@ public class ChannelN extends AMQChannel implements com.rabbitmq.client.Channel
9191 */
9292 public volatile ConfirmListener confirmListener = null ;
9393
94- public volatile ConsumerCancellationListener consumerCancellationListener = null ;
95-
9694 /** Sequence number of next published message requiring confirmation.
9795 */
9896 private long nextPublishSeqNo = 0L ;
@@ -178,15 +176,6 @@ public void setDefaultConsumer(Consumer consumer) {
178176 defaultConsumer = consumer ;
179177 }
180178
181- public ConsumerCancellationListener getConsumerCancellationListener () {
182- return consumerCancellationListener ;
183- }
184-
185- public void setConsumerCancellationListener (
186- ConsumerCancellationListener listener ) {
187- consumerCancellationListener = listener ;
188- }
189-
190179 /**
191180 * Protected API - sends a ShutdownSignal to all active consumers.
192181 * @param signal an exception signalling channel shutdown
@@ -352,12 +341,20 @@ public void releaseChannelNumber() {
352341 // so return false
353342 return false ;
354343 } else if (method instanceof Basic .Cancel ) {
355- ConsumerCancellationListener l = getConsumerCancellationListener ();
356- if (l != null ) {
344+ Basic .Cancel m = (Basic .Cancel )method ;
345+ Consumer callback = _consumers .get (m .consumerTag );
346+ if (callback == null ) {
347+ callback = defaultConsumer ;
348+ }
349+ if (callback != null ) {
357350 try {
358- l . handleConsumerCancellation ((( Basic . Cancel ) method ). getConsumerTag () );
351+ callback . handleCancelNotification ( );
359352 } catch (Throwable ex ) {
360- _connection .getExceptionHandler ().handleConsumerCancellationException (this , ex );
353+ _connection .getExceptionHandler ().handleConsumerException (this ,
354+ ex ,
355+ callback ,
356+ m .consumerTag ,
357+ "handleCancelNotification" );
361358 }
362359 }
363360 return true ;
0 commit comments