-
Notifications
You must be signed in to change notification settings - Fork 586
Add configurable timeout on RPC calls #220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d975201
Add configurable timeout on RPC calls
acogoluegnes 03db046
Add Javadoc to RPC timeout related classes
acogoluegnes 4d8b097
Set default continuation timeout to 10 minutes
acogoluegnes 4688f2a
Remove a sysout
acogoluegnes 8b576a9
Delete unused test class
acogoluegnes 6b5d676
Add channel number to ChannelContinuationTimeoutException
acogoluegnes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/main/java/com/rabbitmq/client/ChannelContinuationTimeoutException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package com.rabbitmq.client; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.concurrent.TimeoutException; | ||
|
|
||
| /** | ||
| * Exception thrown when a channel times out on a continuation during a RPC call. | ||
| * @since 4.1.0 | ||
| */ | ||
| public class ChannelContinuationTimeoutException extends IOException { | ||
|
|
||
| /** | ||
| * The channel that performed the call. | ||
| * Typed as <code>Object</code> as the underlying | ||
| * object that performs the call might | ||
| * not be an implementation of {@link Channel}. | ||
| */ | ||
| private final Object channel; | ||
|
|
||
| /** | ||
| * The number of the channel that performed the call. | ||
| */ | ||
| private final int channelNumber; | ||
|
|
||
| /** | ||
| * The request method that timed out. | ||
| */ | ||
| private final Method method; | ||
|
|
||
| public ChannelContinuationTimeoutException(TimeoutException cause, Object channel, int channelNumber, Method method) { | ||
| super( | ||
| "Continuation call for method " + method + " on channel " + channel + " (#" + channelNumber + ") timed out", | ||
| cause | ||
| ); | ||
| this.channel = channel; | ||
| this.channelNumber = channelNumber; | ||
| this.method = method; | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| * @return request method that timed out | ||
| */ | ||
| public Method getMethod() { | ||
| return method; | ||
| } | ||
|
|
||
| /** | ||
| * channel that performed the call | ||
| * @return | ||
| */ | ||
| public Object getChannel() { | ||
| return channel; | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| * @return number of the channel that performed the call | ||
| */ | ||
| public int getChannelNumber() { | ||
| return channelNumber; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
Channelor am I missing something?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exception is thrown from
AMQChannel, which is not aChannel. There are several other solutions:Channelproperty in the exception and casting theAMQChanneltoChannelwhen throwing the exception. We risk in theory aClassCastException.AMQChannelproperty in the exception, but the implementation leaks up to error handling.I think the third solution is a good compromise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a channel number field (we can keep the field we have with a comment).