Results 1 to 5 of 5

Thread: How does Spring Integration correlate messages?

  1. #1
    Join Date
    May 2012
    Posts
    5

    Question How does Spring Integration correlate messages?

    Lets say that I choose to expose a Spring-WS inbound gateway. While servicing that request, that message may travel across sync/async channels (different threads) to get work done within Spring Integration. When finally finished, how does Spring Integration correlate the reply message (which may have navigated multiple threads) with the original request message in a multi-threaded environment?

    -Joe

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,017

    Default

    The gateway creates a TemporaryReplyChannel object, which is inserted into the replyChannel header, and the gateway waits for a reply.

    In fact, if you explicitly send to the gateway's reply-channel (if declared), all that happens is that channel gets bridged to the replyChannel header.

    It is important not to lose that header en-route.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,017

    Default

    Be aware that, if you go async, the gateway's default timeout is 1 second; this can be increased with reply-timeout.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  4. #4
    Join Date
    May 2012
    Posts
    5

    Default

    Gary,

    Thanks for the quick reply. I am still not clear on how this works though. In a sync. model, all of this would occur on the same thread. If we mixed some async. calls in here, how does the TemporaryReplyChannel object help sync up the reply to the originating request/thread?

  5. #5
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,017

    Default

    The container thread (for a ws inbound gateway), creates a temporary channel, puts it in the header and then waits on its receive(timeout) method.

    The header is passed along to each component (async or not).

    The final consumer (an element that has no output-channel, or one that sends the reply to the gateway's reply-channel) sends the message to that temporary channel, thus waking up the container thread with the result from the receive().

    The correlation is the replyChannel header.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •