From eb341b234a7855624661f40d01b83b4b5bd23cd8 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Thu, 2 Sep 2010 23:25:38 +0000 Subject: [PATCH] INT-1411 added receive and receiveAndConvert methods to AsyncMessagingTemplate and AsyncMessagingOperations --- .../core/AsyncMessagingOperations.java | 12 +++++ .../core/AsyncMessagingTemplate.java | 51 +++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/core/AsyncMessagingOperations.java b/spring-integration-core/src/main/java/org/springframework/integration/core/AsyncMessagingOperations.java index fb9ffd773c..04ba16bf54 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/core/AsyncMessagingOperations.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/core/AsyncMessagingOperations.java @@ -27,6 +27,18 @@ import org.springframework.integration.MessageChannel; */ public interface AsyncMessagingOperations { +

Future> asyncReceive(); + +

Future> asyncReceive(PollableChannel channel); + +

Future> asyncReceive(String channelName); + + Future asyncReceiveAndConvert(); + + Future asyncReceiveAndConvert(PollableChannel channel); + + Future asyncReceiveAndConvert(String channelName); + Future> asyncSendAndReceive(Message requestMessage); Future> asyncSendAndReceive(MessageChannel channel, Message requestMessage); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/core/AsyncMessagingTemplate.java b/spring-integration-core/src/main/java/org/springframework/integration/core/AsyncMessagingTemplate.java index 28bf3df619..ec066ad5ae 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/core/AsyncMessagingTemplate.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/core/AsyncMessagingTemplate.java @@ -93,4 +93,55 @@ public class AsyncMessagingTemplate extends MessagingTemplate implements AsyncMe }); } + public

Future> asyncReceive() { + return this.executor.submit(new Callable>() { + public Message

call() throws Exception { + return receive(); + } + }); + } + + public

Future> asyncReceive(final PollableChannel channel) { + return this.executor.submit(new Callable>() { + public Message

call() throws Exception { + return receive(channel); + } + }); + } + + public

Future> asyncReceive(final String channelName) { + return this.executor.submit(new Callable>() { + public Message

call() throws Exception { + return receive(channelName); + } + }); + } + + @SuppressWarnings("unchecked") + public Future asyncReceiveAndConvert() { + return this.executor.submit(new Callable() { + public R call() throws Exception { + return (R) receiveAndConvert(); + } + }); + } + + @SuppressWarnings("unchecked") + public Future asyncReceiveAndConvert(final PollableChannel channel) { + return this.executor.submit(new Callable() { + public R call() throws Exception { + return (R) receiveAndConvert(channel); + } + }); + } + + @SuppressWarnings("unchecked") + public Future asyncReceiveAndConvert(final String channelName) { + return this.executor.submit(new Callable() { + public R call() throws Exception { + return (R) receiveAndConvert(channelName); + } + }); + } + }