Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Workflow - PersistableIdle

In our company we have a business process that needs to:

  1. Get data from X
  2. Wait for user Y to do research
  3. Get data from Z based on step 2 data

In researching this, it seems like there are a few options to implement this in workflow.

  1. Add a delay activity between Step 1 (workflow activity) and Step 3 (workflow activity). Then during the PersistableIdle event, unload the worklow. When the user is done with step 2, re-load workflow from database.
  2. Same as #1 except use a bookmark instead of a delay activity.

Is there a better approch (1, 2 or another option)?

All of our other activities are AsyncCodeActivities, so I'm fairly sure they will not fire the PersistableIdle event (since they are in a no-persist zone), but I want to make sure the workflow is not accidentally unloaded in other cases. Is there any risk here? Is there anyway to create an activity that forces the workflow to unload?

like image 303
user472292 Avatar asked Nov 25 '11 21:11

user472292


People also ask

Is Windows Workflow Foundation deprecated?

Windows Workflow Foundation, aka WF, is no longer supported in the new . NET 6.

What is Windows Workflow Foundation used for?

Windows Workflow Foundation (WWF or WF) is a framework for creating and managing workflows within . NET applications. It treats each step of a process as an activity, working with a . NET library of activities and adding custom activities for other kinds of functionality.

How do I pause workflow?

To pause a workflow, use Unload. This method requests that the workflow persist and unload, and will throw a TimeoutException if the workflow does not unload in 30 seconds.


1 Answers

Is there a better approach (1, 2 or another option)?

At first glance, #2 sounds like necessary. The reason to use bookmarks (or bookmarking activity of some kind, like Receive) is that they can be resumed any time. This allows for user Y's research to end and the workflow to resume execution at any time (instead of being blocked until a Delay expires).

The counterargument, that #1 may be necessary too, is that you may wish to set a time limit which triggers workflow actions (reminders being fired off, exceptions, cancellations, etc).

How to decide? I think the answer is usually #3: Both

Using Pick Activity is a great way to do both. Using Bookmarking activity in one PickBranch trigger, and Delay activity in the other PickBranch trigger, you can compose a workflow which will 'handle whichever happens first - user Y, or timeout'.

A secondary question you raise is 'How do I stop a Workflow being unloaded when I don't want it to be - is surprise workflow unloading a risk'?

Well, that depends. If you are using WorkflowServiceHost, having your workflow unloaded doesn't feel like a big risk, because the WorfklowServiceHost is smart enough to reload your workflow when it needs to do more work (handle an incoming message, or resume from delay).

If you are not using WorkflowServiceHost, you are probably writing your host, you can either achieve the same effect with some work, or you can just prevent unloading from happening ever - when you write the host, you control the unload policy, via the events on WorkflowApplication

Other miscellaneous points: -Asynchronous Code Activities do indeed prevent your workflow from persisting while they are doing asynchronous work. I don't think they should be deliberately used as an anti-persistance mechanism though - if you want one of those, check out NoPersistZone activity.

-There is no 'Unload' activity, but there is a 'Persist' activity. Workflows can say they want to save progress, but only the host gets to make the finally decision on when unloading happens.

like image 69
Tim Lovell-Smith Avatar answered Sep 26 '22 15:09

Tim Lovell-Smith