views:

133

answers:

1

Hello Gurus,

I'm working on a asp.net mvc project that will use MS Windows Workflow Foundation to manage client business work flows. These are long running workflows spanning in time over a year or two. So we've decided to use State Machine workflows. A workflow instance will be persisted to a database when not being used (or in idle).

I'm fairly new to MS WF and would like to find out the best practices for implementing the workflows for an asp.net mvc application.

More specifically, where should I host the WF runtime? In asp.net mvc or in a separate process like Windows Service?

I would be most grateful to hear success stories of how MS WF is implemented in asp.net mvc?

Any comments and ideas are welcome,

Thank you all,

Cullen

+3  A: 

Are you referring to WF3 or WF4 which is a completely different piece of code.

With WF3 there is the central WorkflowRuntime and that is usually hosted somewhere at the application or possibly session level.

Updated Some of the things to watch out for:

  • IIS can recycle the AppDomain at any time it wants to when there are no incoming calls being processed. An async workflow is NOT considered part of the request as it is running on another thread.
  • To migrate workflows from the old to the new AppDomain you need a persistence service.
  • The new AppDomain might not be activated right away causing delay activities not to execute as soon as you would expect.
  • Its is generally best to use the manual workflow scheduler but that makes writing code somewhat more complex as you have to schedule the work and then start execution.
Maurice
@Maurice: I'm using WF3.5.
Cullen Tsering
@Maurice: I understand that the runtime can be hosted anywhere but I'd like to find out the pros and cons of hosting it in certain environment.
Cullen Tsering
@Maurice: thanks for the response; We'll definitely persist the workflow instance between user interactions;
Cullen Tsering
+1 But the last point should be first and stated more strongly, if hosting Workflow in ASP.NET its much better to use the manual workflow scheduler. One reason is the first point. By using manual scheduling the vast majority of workflow code will be running in the context of a Request, a recycle won't interrupt assuming the workflow doesn't take too long to idle.
AnthonyWJones