Dec 21st, 2012, 09:54 AM
Making Async calls to HTTP Outbound Gateway.
I have a system that I am looking at retrofitting a backend with spring integration.
A few of the patterns in this system, look at hitting the same web service and/or HTTP server (I have both) with multiple requests and slightly different parameters. The results are then aggregated together and presented to the user
I have it working successfully in a synchronous mode, where the request comes in thru a Gateway, is "split" into messages that contain the key value for each call (call with A, call with B, call with XYZ). Each message then goes to an HTTP Outbound Gateway, the call is made, and is returned. The results are then aggregated together and shipped back through the Gateway.
What I'm struggling with is making these HTTP calls asynchronously. The current system uses Futures to make each call in a separate thread. I would like a similar pattern.
What I think I need to do is to create a second Gateway, which wraps the HTTP outbound gateway, and use the <Future> return value to create an async call. However, I'm not sure how this would work with the aggregation, and something about it feels like there should be a cleaner way. I haven't had the opportunity to use Spring Integration in 3 years, so I'm trying to relearn all the things.
Am I missing something, or is this how you need to do it?