Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dealing with a longer running process in WCF

Tags:

wcf

In the app I'm currently working on we are using a couple of WCF services with a lot of methods. Until now, all methods are very short running, often just getting some data. I've just added a method that takes a way longer time to run.

I do not want to raise the timeout in the config, because 1 minute is long enough for all other methods on the service.

What is the best way to deal with 1 longer running method? And how do I provide feedback that it is still running?

like image 454
Sorskoot Avatar asked Jan 24 '23 10:01

Sorskoot


2 Answers

A long running task should really be farmed off as an asynchronous call, that could then be polled for status (or an event through a duplex connection). For a really long running task, you might even want to push it into something like Windows Workflow.

like image 131
Steve Gilham Avatar answered Jan 26 '23 00:01

Steve Gilham


Combining WCF with WF (Workflow Foundation) seems like the best option here. Workflow Foundation gives you lots of goodies, including long-term persistence over the lifetime of your long-running process.

In .NET 3.5, it's possible to do so, but clumsy and a lot of work.

Here are a few links for this topic:

  • http://channel9.msdn.com/posts/mwink/Introduction-to-Workflow-Services-building-WCF-Services-with-WF/
  • http://code.msdn.microsoft.com/WorkflowServices
  • http://msdn.microsoft.com/en-us/magazine/cc164251.aspx

With .NET 4.0, these "WorkflowServices" will be a big part of the new WF/WCF 4.0 package. You should basically be able to expose an interface for any workflow as a WCF service. Sounds very promising, haven't had a chance to try it myself.

Some links for the new stuff:

  • WCF / WF 4.0 and "Dublin"
  • http://blogs.msdn.com/murrayg/archive/2009/06/23/windows-azure-s-net-workflow-service-to-support-net-4-0-workflows.aspx
  • http://channel9.msdn.com/shows/10-4/10-4-Episode-24-Monitoring-Workflow-Services/
  • http://channel9.msdn.com/shows/10-4/10-4-Episode-16-Windows-Workflow-4/

Marc

like image 42
marc_s Avatar answered Jan 26 '23 00:01

marc_s