Got a question regarding best practices for doing parallel web service calls, in a web service.
Our portal will get a message, split that message into 2 messages, and then do 2 calls to our broker. These need to be on separate threads to lower the timeout.
One solution is to do something similar to (pseudo code):
XmlNode DNode = GetaGetDemoNodeSomehow();
XmlNode ENode = GetAGetElNodeSomehow();
XmlNode elResponse;
XmlNode demResponse;
Thread dThread = new Thread(delegate
{
//Web Service Call
GetDemographics d = new GetDemographics();
demResponse = d.HIALRequest(DNode);
});
Thread eThread = new Thread(delegate
{
//Web Service Call
GetEligibility ge = new GetEligibility();
elResponse = ge.HIALRequest(ENode);
});
dThread.Start();
eThread.Start();
dThread.Join();
eThread.Join();
//combine the resulting XML and return it.
//Maybe throw a bit of logging in to make architecture happy
Another option we thought of is to create a worker class, and pass it the service information and have it execute. This would allow us to have a bit more control over what is going on, but could add additional overhead.
Another option brought up would be 2 asynchronous calls and manage the returns through a loop. When the calls are completed (success or error) the loop picks it up and ends.
The portal service will be called about 50,000 times a day.
I don't want to gold plate this sucker.
I'm looking for something light weight. The services that are being called on the broker do have time out limits set, and are already heavily logged and audited, so I'm not worried on that part.
This is .NET 2.0 , and as much as I would love to upgrade I can't right now. So please leave all the goodies of 2.0 out please.