You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Future<Message> as a result of MessageChannelTemplate.sendAndReceive [INT-972] #4982
sendAndReceive has a unique and useful feature: temporary reply channel, but it's a synchronous method. So it would be useful to have an asynchronous method to send to a few channels and wait for all to reply. It might have a very similar API like this:
Future<Message<?>> sendAndReceiveFuture(final Message<?> request, final MessageChannel channel)
The changes in the code would be relatively small. Without this feature and without a temporary reply channel available as public class it's very hard to send to a few channels and wait for replies in parallel.
I have some code like this in the sandbox. The main question I have is whether it should be a new method ("asyncSendAndReceive") or a new class AsyncMessageChannelTemplate.
IMO it must be a new method. Of course sendAndReceiveFuture is a word play (Future version of the same method and "receive Future<>" instead of receiving message), and async is better name.
So I think a new method is better because send() is already asynchronous (if the channel is a queue) and the receive() must stay synchronous because there is no point to get a Future of a random channel message. But sendAndReceive() is the only method (I ignore the convention overload) which can give added value by sending now and receiving later.
It definitely makes sense. In fact, your point about the "send" already being async if the channel itself is makes me wonder if 'asyncSendAndReceive' might not be such a great name after all. Maybe something like 'asyncSendAndReceiveLater' would be better :)
Activity
spring-operator commentedon Jan 28, 2010
Mark Fisher commented
I have some code like this in the sandbox. The main question I have is whether it should be a new method ("asyncSendAndReceive") or a new class AsyncMessageChannelTemplate.
spring-operator commentedon Jan 28, 2010
Andrew Skiba commented
IMO it must be a new method. Of course sendAndReceiveFuture is a word play (Future version of the same method and "receive Future<>" instead of receiving message), and async is better name.
So I think a new method is better because send() is already asynchronous (if the channel is a queue) and the receive() must stay synchronous because there is no point to get a Future of a random channel message. But sendAndReceive() is the only method (I ignore the convention overload) which can give added value by sending now and receiving later.
Hope that makes sense.
spring-operator commentedon Jan 28, 2010
Mark Fisher commented
It definitely makes sense. In fact, your point about the "send" already being async if the channel itself is makes me wonder if 'asyncSendAndReceive' might not be such a great name after all. Maybe something like 'asyncSendAndReceiveLater' would be better :)
spring-operator commentedon Feb 16, 2010
Andrew Skiba commented
Patch with basic implementation of the feature.
spring-operator commentedon Feb 16, 2010
Andrew Skiba commented
fixed patch
spring-operator commentedon Nov 13, 2014
Artem Bilan commented
Fixed with #5406