INT-1411 added receive and receiveAndConvert methods to AsyncMessagingTemplate and AsyncMessagingOperations

This commit is contained in:
Mark Fisher
2010-09-02 23:25:38 +00:00
parent da83e4c2e1
commit eb341b234a
2 changed files with 63 additions and 0 deletions

View File

@@ -27,6 +27,18 @@ import org.springframework.integration.MessageChannel;
*/
public interface AsyncMessagingOperations {
<P> Future<Message<P>> asyncReceive();
<P> Future<Message<P>> asyncReceive(PollableChannel channel);
<P> Future<Message<P>> asyncReceive(String channelName);
<R> Future<R> asyncReceiveAndConvert();
<R> Future<R> asyncReceiveAndConvert(PollableChannel channel);
<R> Future<R> asyncReceiveAndConvert(String channelName);
Future<Message<?>> asyncSendAndReceive(Message<?> requestMessage);
Future<Message<?>> asyncSendAndReceive(MessageChannel channel, Message<?> requestMessage);

View File

@@ -93,4 +93,55 @@ public class AsyncMessagingTemplate extends MessagingTemplate implements AsyncMe
});
}
public <P> Future<Message<P>> asyncReceive() {
return this.executor.submit(new Callable<Message<P>>() {
public Message<P> call() throws Exception {
return receive();
}
});
}
public <P> Future<Message<P>> asyncReceive(final PollableChannel channel) {
return this.executor.submit(new Callable<Message<P>>() {
public Message<P> call() throws Exception {
return receive(channel);
}
});
}
public <P> Future<Message<P>> asyncReceive(final String channelName) {
return this.executor.submit(new Callable<Message<P>>() {
public Message<P> call() throws Exception {
return receive(channelName);
}
});
}
@SuppressWarnings("unchecked")
public <R> Future<R> asyncReceiveAndConvert() {
return this.executor.submit(new Callable<R>() {
public R call() throws Exception {
return (R) receiveAndConvert();
}
});
}
@SuppressWarnings("unchecked")
public <R> Future<R> asyncReceiveAndConvert(final PollableChannel channel) {
return this.executor.submit(new Callable<R>() {
public R call() throws Exception {
return (R) receiveAndConvert(channel);
}
});
}
@SuppressWarnings("unchecked")
public <R> Future<R> asyncReceiveAndConvert(final String channelName) {
return this.executor.submit(new Callable<R>() {
public R call() throws Exception {
return (R) receiveAndConvert(channelName);
}
});
}
}