Announcement Announcement Module
Collapse
No announcement yet.
Future<Message> as a result of MessageChannelTemplate.sendAndReceive Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Future<Message> as a result of MessageChannelTemplate.sendAndReceive

    Hello again!

    I need to send the same message to a few handlers in parallel and wait until they send the results back.

    If MessageChannelTemplate would return Future<Message>, I could send all messages and wait for the futures to complete. The best option I see is to copy some code (including TemporaryReplyChannel) from MessageChannelTemplate.

    Or maybe there is a better option?

  • #2
    There should be an easy way to do what you're trying to do. I'm not sure if it belongs in MessageChannelTemplate (need to think a bit), but if you'd like to open an issue in JIRA, please do.

    Comment


    • #3
      Done: http://jira.springframework.org/browse/INT-972

      Comment


      • #4
        I think you might find it easier to aggregate the replies in an aggregator, or use the executor API directly. It depends on which granularity better matches your problem.

        Comment


        • #5
          Well, everything is doable in any Turing complete language. But the solution might be complex.

          I need to use sendAndReceive with channel and service activator created dynamically by my code. So with aggregator I would need to create another channel for getting all results mixed, and also create an aggregator and wire everything. On the other hand with sendAndReceive returning Future, the code is very short and readable. And the implementation is quite trivial, I can prepare a patch.

          Comment


          • #6
            Originally posted by andrewsk View Post
            And the implementation is quite trivial, I can prepare a patch.
            Please do, it will probably help me understand

            Comment


            • #7
              I created the basic patch: http://jira.springframework.org/secu...6/future.patch

              It lacks transaction handling, and the exception part is ugly, but it's enough to explain the idea.

              P.S. forgot to run the future task, please look at the fixed patch: http://jira.springframework.org/secu...7/future.patch
              Last edited by andrewsk; Feb 17th, 2010, 03:59 AM.

              Comment


              • #8
                I glanced over the patch, and I can see some places where it would be useful. Let's move the discussion over to the issue (also make sure to attach/link the patch there).

                Comment


                • #9
                  Sure, the patch is attached to the JIRA issue. Waiting to your comments.

                  Comment

                  Working...
                  X