Sync Parallel Processing

I have a requirement where I need to expose a web service which will in turn search for some data from two different system (e.g. System A and System B) by calling specific web services exposed by System A and System B.

The data could be found in either or both of the system and I need to aggregate the data and return back to the main web service call.

This complete processing needs to be executed in a synchronous way.

To minimise the overall time taken by my main web service I want to execute the System A and System B web service parallelly in the main web service and once the response is back from both the system aggregate it and return it back.

Not sure, what is the best approach to achieve this, your suggesting will be of great help.

You can use an async pub/wait in your service. That will allow you to send out two request at the same time and marry up the responses. Pub/sub guide will give you the details on using it.

I actually want to achieve this in a synchronous process.

One way I could think of is that as soon I get a call to my main web service I publish a document, which can in turn subscribe by the consumer of System A and System B web services and then publish the search result respectively.

I can then have a subscriber with a join condition waiting for responses from System A and System B.

This option looks ok in case everything works fine, however I am not too sure if one of the system processing get stuck, how to handle that.

Is there any better approach?

You might want to read up on how the asynch pub/wait works, it will accomplish, without all the steps you just mentioned, what you want to do. You web service will still behave in a syncronous manner to the calling application. The asynch pub/wait is more akin to a callback.

Mark’s suggestion to use request/reply will work.

Another way is to use doThreadInvoke in the IS API to invoke local services that make calls to the remote web services. Then join the threads. The threads can have wait timeouts.

Conceptually, this is the same thing as the request/reply via Broker. Just different in the implementation details.

Thanks Mark & Rob,

I have now understood both the approaches. However I have one more point to clarify in the approach suggested by Mark.

For a request/reply I could either use “publishAndWait” or “deliverAndWait” asynchronously, and then use “waitForReply” to capture the response. Could you please suggest that, if I am only going to have one subscriber for each publishable document then which one is the better approach?

I would recommend publishAndWait.