One SQL store, multiple WorkflowApplications (Locks) RRS feed

  • Question

  • I'm getting very confusing behaviour from WorkflowFoundation 4.5 when trying to persist and unload/reload instances and dealing with bookmarks combined with delay activities. For testing purposes I am just using a workflow definition with 2 states and an exit state. There is a delay between the two states, and a user input activity (using a bookmark) on the first state that feeds back into itself which can update the data, and transition the workflow instance to the exit state.

    When running in memory (persist, no unload) this workflow works just fine. However I will need thousands of instances so this needs to work with persistence. Running the "happy" path with an instance started and transitioning between state 1 & 2 worked fine, At best I did get it working with an SQL Instance Store per WorkflowApplication, but the bookmark only worked when the WFApplication was loaded from the instance store. (I.e. created, have the app closed, restarted which resumed the workflow with a .Load) If the bookmark was triggered on the new WFApplication it never unloaded and even a WriteLine in the Bookmark activity action never fired. Also, I had been getting instance lock and similar exceptions when attempting to resume persisted workflows with .Load.

    I've tried moving to a single SQL Instance Store by using the whole

    			_instanceStore = new SqlWorkflowInstanceStore(ConfigurationManager.ConnectionStrings["MedapointWF"].ConnectionString);
    			_defaultInstanceHandle = _instanceStore.CreateInstanceHandle();
    			var view = _instanceStore.Execute(_defaultInstanceHandle, new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(10));
    			_instanceStore.DefaultInstanceOwner = view.InstanceOwner;

    with a .Execute(...., new DeleteWorkflowOwnerComand()....) when the application shuts down, but that doesn't help, it still complains when attempting to load workflows.

    I cannot even begin to list the various things I have tried with this code, and it's really beginning to tick me off why this persistence is so damned finnicky. I have been trying to find ANY example of a workflow solution that is capable of opening MORE THAN ONE WorkflowApplication at a time, persist them, resume them, and interact with Bookmarks. I've heard references about associating instance owners on a per-WorkflowApplication but looking at the object model I see no way to associate an owner with a WorkflowApplication. The terminology used in WF is still confusing as it would seem that InstanceHandles can be linked to WorkFlowApplications (as the persistence for the instance running the ID is called InstanceId) but I see no examples of either tying an InstanceHandle to a WFApplication, or an Owner for that matter.

    If someone can point me at an actual example that persists multiple workflowApplication instances to a datastore, ideally that utilizes Delay activities and bookmarks I would be most appreciative.

    #2 happens.

    Friday, June 28, 2013 2:00 PM