Skip to content

Commit 03afbbe

Browse files
author
Matthew Sackman
committed
And now implement it all this way instead, which is a fair bit nicer
1 parent 3136f72 commit 03afbbe

File tree

6 files changed

+18
-23
lines changed

6 files changed

+18
-23
lines changed

src/com/rabbitmq/client/Channel.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ public interface Channel extends ShutdownNotifier {
180180
*/
181181
void setDefaultConsumer(Consumer consumer);
182182

183-
ConsumerCancellationListener getConsumerCancellationListener();
184-
void setConsumerCancellationListener(ConsumerCancellationListener notifier);
185-
186183
/**
187184
* Request specific "quality of service" settings.
188185
*

src/com/rabbitmq/client/Consumer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,6 @@ void handleDelivery(String consumerTag,
8282
AMQP.BasicProperties properties,
8383
byte[] body)
8484
throws IOException;
85+
86+
void handleCancelNotification() throws IOException;
8587
}

src/com/rabbitmq/client/DefaultConsumer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ public void handleDelivery(String consumerTag,
7979
// no work to do
8080
}
8181

82+
public void handleCancelNotification() throws IOException {
83+
// no work to do
84+
}
85+
8286
/**
8387
* Retrieve the channel.
8488
* @return the channel this consumer is attached to.

src/com/rabbitmq/client/impl/ChannelN.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

src/com/rabbitmq/client/impl/ExceptionHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,4 @@ void handleConsumerException(Channel channel,
7979
String consumerTag,
8080
String methodName);
8181

82-
void handleConsumerCancellationException(Channel channel, Throwable exception);
8382
}

test/src/com/rabbitmq/client/test/AMQConnectionTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,6 @@ public void handleConsumerException(Channel ch,
197197
fail("handleConsumerException " + consumerTag + " " + methodName + ": " + ex);
198198
}
199199

200-
public void handleConsumerCancellationException(Channel channel, Throwable ex) {
201-
fail("handleConsmuerCancellationException " + ex);
202-
}
203-
204200
public List<Throwable> getHandledExceptions() {
205201
return _handledExceptions;
206202
}

0 commit comments

Comments
 (0)