Skip to content

Commit 6b5d676

Browse files
committed
Add channel number to ChannelContinuationTimeoutException
Fixes #219
1 parent 8b576a9 commit 6b5d676

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

src/main/java/com/rabbitmq/client/ChannelContinuationTimeoutException.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,53 @@ public class ChannelContinuationTimeoutException extends IOException {
1111

1212
/**
1313
* The channel that performed the call.
14+
* Typed as <code>Object</code> as the underlying
15+
* object that performs the call might
16+
* not be an implementation of {@link Channel}.
1417
*/
1518
private final Object channel;
1619

20+
/**
21+
* The number of the channel that performed the call.
22+
*/
23+
private final int channelNumber;
24+
1725
/**
1826
* The request method that timed out.
1927
*/
2028
private final Method method;
2129

22-
public ChannelContinuationTimeoutException(TimeoutException cause, Object channel, Method method) {
23-
super(cause);
30+
public ChannelContinuationTimeoutException(TimeoutException cause, Object channel, int channelNumber, Method method) {
31+
super(
32+
"Continuation call for method " + method + " on channel " + channel + " (#" + channelNumber + ") timed out",
33+
cause
34+
);
2435
this.channel = channel;
36+
this.channelNumber = channelNumber;
2537
this.method = method;
2638
}
2739

40+
/**
41+
*
42+
* @return request method that timed out
43+
*/
2844
public Method getMethod() {
2945
return method;
3046
}
3147

48+
/**
49+
* channel that performed the call
50+
* @return
51+
*/
3252
public Object getChannel() {
3353
return channel;
3454
}
55+
56+
/**
57+
*
58+
* @return number of the channel that performed the call
59+
*/
60+
public int getChannelNumber() {
61+
return channelNumber;
62+
}
3563
}

src/main/java/com/rabbitmq/client/impl/AMQChannel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ private AMQCommand privateRpc(Method m)
250250
} catch(Exception ex) {
251251
LOGGER.warn("Error while cleaning timed out channel RPC: {}", ex.getMessage());
252252
}
253-
throw new ChannelContinuationTimeoutException(e, this, m);
253+
throw new ChannelContinuationTimeoutException(e, this, this._channelNumber, m);
254254
}
255255
}
256256
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public class AMQChannelTest {
6969
} catch(ChannelContinuationTimeoutException e) {
7070
// OK
7171
assertThat((DummyAmqChannel) e.getChannel(), is(channel));
72+
assertThat(e.getChannelNumber(), is(channel.getChannelNumber()));
7273
assertThat(e.getMethod(), is(method));
7374
assertNull("outstanding RPC should have been cleaned", channel.nextOutstandingRpc());
7475
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public void tearDown() throws Exception {
7676
} catch(ChannelContinuationTimeoutException e) {
7777
// OK
7878
assertThat((Channel) e.getChannel(), is(channel));
79+
assertThat(e.getChannelNumber(), is(channel.getChannelNumber()));
7980
assertThat(e.getMethod(), instanceOf(AMQP.Queue.Declare.class));
8081
}
8182
} finally {

0 commit comments

Comments
 (0)