Results 1 to 3 of 3

Thread: Making Async calls to HTTP Outbound Gateway.

  1. #1
    Join Date
    Dec 2012
    Posts
    2

    Default 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?

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

    Default

    You can simply make the channels (to which the outbound-gateways are subscribed) ExecutorChannels (http://static.springsource.org/sprin...ecutor-channel and http://static.springsource.org/sprin...xecutorchannel).

    That way, each request will run on a separate thread - the aggregation release will occur on the thread that receives the final response. Your original thread will wait in the gateway for the response (or you can use an async gateway and wait on a Future.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    Dec 2012
    Posts
    2

    Default

    Thank you. I knew it was something "obvious" that I missed. I just need to understand how failover will work now.

Posting Permissions

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