Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calls between services 1

Status
Not open for further replies.
Jul 29, 2005
136
PT
Hello all,

I have a service that need to make a call to another service. Because the second service may take sometime to do what it needs to do, I would like service 2 to make a response to service 1 as soon as possible, even if it didn´t finished is work. I think this is not like an async processing in service 2 because after service 2 makes the response I don´t want it to make a second response... Any ideas on this?

Thank you
 
processes execution is linear or parallel.
linear: all commands are executed on the same thread. the next process will not fire until the current process is complete.
parallel: execute specificed commands on a child thread. 2 tasks will run concurrently. there is no way to predict which task will complete first.

you could use System.Threading.Thread, BackgroundWorker object, Custom Callbacks/IAsyncResult object or a messaging service (MSMQ) to complete tasks in parallel.

MSMQ is an OS service. The framework has an API to MSMQ. the rest can be created in code.

one last thing to note a parallel processing. you cannot share object across threads.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Do you need to notify the caller of service 2's completion, even if the caller may not want to block until that point? Otherwise, would jmeckley's suggestion of using a child thread work for your purposes?

MCP, MCTS - .NET Framework 2.0 Web Applications
 
Hello,

I just want service1 to make a call to service2, and have service2 to grab all the parameters and give an immediatly response to service2 (as if it´s work was finish, because I want service1 to response imediatly to is caller too). Despite service1 will receive very soon the response, service2 will continue to process the call, but it will not contact service1 anymore. In a webservice/web method I see service2 given the response at the final of the method.But how can I make it continue some work? Any example? Im not seeing the big picture of this working...
 
this is an asynchronous operation. so you need to setup service to make async requests. here is an msdn article which may be helpful.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Actually with web services, it's really easy to set up asychronous calls!

If you're using a .NET web service proxy (the widget you get after adding a "web reference"), then you'd have access to asychrounous versions of all the web services automatically.

For instance, if you have a "HelloWorld()" web method, then you should have a "HelloWorldAsync()" method in the generated proxy.

Therefore, you can have "service 1" add a web reference to "service 2", then have "service 1"'s method use the asychronous version of the method you want to call in "service 2".


That said, if the method you're calling in "service 2" should never block before returning (you want it to be fire-and-forget), then you'll simply want to decorate its web method with an attribute indicating that it's a "one-way" call:

Code:
[SoapDocumentMethod(OneWay=true)]
[WebMethod]
public void MyOneWayMethod(string input) //No return value
{
   //code here
}

MCP, MCTS - .NET Framework 2.0 Web Applications
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top