16 November, 2011

FIM 2010: How to make a workflow persist

Having used an extensive amount of time with WF 3.5 and FIM 2010 in combination; it has become evident to me that it is not all that obvious how you enable persistence of a FIM-hosted workflow?

Normally when working with WF you control the hosting environment (runtime-environment) and as such are in full control when it comes to persistence and tracing of workflows; as you add these features yourself when initializing the runtime. This is not the case in FIM where the runtime is provided to you (by the Microsoft.ResourceManagement.Service.exe file [Window Service]). You would then potentially expect to find an entry in <app>.config for this service about persistence; but alas this is not so. You actually need to open up the assemblies using Reflector to detect the whereabouts of this functionality!

Why is this needed or even relevant you might rightfully ask? If your workflowinstance is shut down during execution or power of the server is killed during execution, your workflow will attempt to resume from latest persistence point (if one exists!) when power is restored. A persistence point is the lastknown good state of your workflow.

So – how do you enable this stuff? It so happens that persistence is enabled by default in the WF-runtime provided by FIM. The database this persistence-service uses is the std. FIMServiceDB which by default is named: “FIMService”. You can see the tables involved here:

Persistence tables

Great – so what do you have to do to use this from within your own workflows?

Out-of-the-box, you can use the DelayActivity (std. workflow). This activity will persist the current workflow instance to the database tables when entered.


You can also force persistence at an arbitrary point in your workflow by adding your own persistence points. You do so by creating a new Activity and decorate this with the [PersistOnClose]-attribute.


This will make the WF-runtime persist the workflow instance to the database as soon as this activity leaves it’s executemethod with a resultcode = ActivityExecutionStatus.Closed;

That’s what it takes to enable and use persistence…


StackOverflow Tags:

No comments:

iPhone/XCode - not all cases are equal!

This bit me! Having made some changes to an iPhone application (Obj-C); everything worked fine in the simulator. But, when deploying the s...