This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

How does Spring Integration correlate messages?

May 16th, 2012, 08:08 AM

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?

Comment

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?

Comment

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().