Restarting a persisted workflow using a self-hosted WorkflowServiceHost

1.2k views Asked by At

I'm trying to work out how to resume a persisted workflow that I'm self-hosting with a WorkflowServiceHost. Currently my host wires up persistence and idling behaviour like so:

        // Persistence
        var connStr = @"";
        var behavior = new SqlWorkflowInstanceStoreBehavior(connStr);
        behavior.InstanceCompletionAction = InstanceCompletionAction.DeleteNothing;
        behavior.InstanceLockedExceptionAction = InstanceLockedExceptionAction.AggressiveRetry;
        behavior.InstanceEncodingOption = InstanceEncodingOption.None;
        host.Description.Behaviors.Add(behavior);

        // Idle behaviour
        var idleBehavior = new WorkflowIdleBehavior();
        idleBehavior.TimeToPersist = TimeSpan.FromMinutes(2);
        idleBehavior.TimeToUnload = TimeSpan.FromMinutes(2);
        host.Description.Behaviors.Add(behavior);

I am storing the workflow instance GUID against a ProductID in my database inside a custom activity contained in the workflow, so I am able to easily trace a specific workflow instance to a product ID. I want to be able to somehow pass this Product ID to my ServiceHost and have it resume the correct persisted workflow for me.

Can anyone point me in the right direction on how to do this?

Many thanks in advance Ian

1

There are 1 answers

4
Thelonias On BEST ANSWER

You're going to want to read about Content Correlation. You'll correlate your ProductID with your Receive activities. A bookmark will be created when you reach a receive, and your workflow will be persisted. You call the receive and pass your ProductID in and because of the correlation, the WF runtime knows which instance to resume.