-
Notifications
You must be signed in to change notification settings - Fork 584
Add CompletableFuture async RPC to channel #257
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 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
05dcfc4
Add CompletableFuture async RPC to channel
acogoluegnes d813c08
Compose CompletableFuture in async test
acogoluegnes f6192e3
Reuse logic when enqueueing RPC in Channel
acogoluegnes d9f5aec
Add Javadoc to Channel#asyncCompletableRpc
acogoluegnes 4362048
Merge branch 'master' into rabbitmq-java-client-215
michaelklishin 7f4c09f
Add publisher confirms to this test
michaelklishin 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
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
43 changes: 43 additions & 0 deletions
43
src/main/java/com/rabbitmq/client/impl/CompletableFutureRpcWrapper.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,43 @@ | ||
// Copyright (c) 2017-Present Pivotal Software, Inc. All rights reserved. | ||
// | ||
// This software, the RabbitMQ Java client library, is triple-licensed under the | ||
// Mozilla Public License 1.1 ("MPL"), the GNU General Public License version 2 | ||
// ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see | ||
// LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, | ||
// please see LICENSE-APACHE2. | ||
// | ||
// This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, | ||
// either express or implied. See the LICENSE file for specific language governing | ||
// rights and limitations of this software. | ||
// | ||
// If you have any questions regarding licensing, please contact us at | ||
// [email protected]. | ||
|
||
package com.rabbitmq.client.impl; | ||
|
||
import com.rabbitmq.client.Command; | ||
import com.rabbitmq.client.ShutdownSignalException; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* | ||
*/ | ||
public class CompletableFutureRpcWrapper implements RpcWrapper { | ||
|
||
private final CompletableFuture<Command> completableFuture; | ||
|
||
public CompletableFutureRpcWrapper(CompletableFuture<Command> completableFuture) { | ||
this.completableFuture = completableFuture; | ||
} | ||
|
||
@Override | ||
public void complete(AMQCommand command) { | ||
completableFuture.complete(command); | ||
} | ||
|
||
@Override | ||
public void shutdown(ShutdownSignalException signal) { | ||
completableFuture.completeExceptionally(signal); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/rabbitmq/client/impl/RpcContinuationRpcWrapper.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,40 @@ | ||
// Copyright (c) 2017-Present Pivotal Software, Inc. All rights reserved. | ||
// | ||
// This software, the RabbitMQ Java client library, is triple-licensed under the | ||
// Mozilla Public License 1.1 ("MPL"), the GNU General Public License version 2 | ||
// ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see | ||
// LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, | ||
// please see LICENSE-APACHE2. | ||
// | ||
// This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, | ||
// either express or implied. See the LICENSE file for specific language governing | ||
// rights and limitations of this software. | ||
// | ||
// If you have any questions regarding licensing, please contact us at | ||
// [email protected]. | ||
|
||
package com.rabbitmq.client.impl; | ||
|
||
import com.rabbitmq.client.ShutdownSignalException; | ||
|
||
/** | ||
* | ||
*/ | ||
public class RpcContinuationRpcWrapper implements RpcWrapper { | ||
|
||
private final AMQChannel.RpcContinuation continuation; | ||
|
||
public RpcContinuationRpcWrapper(AMQChannel.RpcContinuation continuation) { | ||
this.continuation = continuation; | ||
} | ||
|
||
@Override | ||
public void complete(AMQCommand command) { | ||
continuation.handleCommand(command); | ||
} | ||
|
||
@Override | ||
public void shutdown(ShutdownSignalException signal) { | ||
continuation.handleShutdownSignal(signal); | ||
} | ||
} |
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,29 @@ | ||
// Copyright (c) 2017-Present Pivotal Software, Inc. All rights reserved. | ||
// | ||
// This software, the RabbitMQ Java client library, is triple-licensed under the | ||
// Mozilla Public License 1.1 ("MPL"), the GNU General Public License version 2 | ||
// ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see | ||
// LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, | ||
// please see LICENSE-APACHE2. | ||
// | ||
// This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, | ||
// either express or implied. See the LICENSE file for specific language governing | ||
// rights and limitations of this software. | ||
// | ||
// If you have any questions regarding licensing, please contact us at | ||
// [email protected]. | ||
|
||
package com.rabbitmq.client.impl; | ||
|
||
import com.rabbitmq.client.ShutdownSignalException; | ||
|
||
/** | ||
* | ||
*/ | ||
public interface RpcWrapper { | ||
|
||
void complete(AMQCommand command); | ||
|
||
void shutdown(ShutdownSignalException signal); | ||
|
||
} |
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.
Since this is a public method, I'd like to clarify the name. How about
exceptionWrappingAsyncRpc
?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.
I now see we already have a "non-async" method with a similar name from way back. Disregard the above.