开发者

Restarting a persisted workflow using a self-hosted WorkflowServiceHost

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:

        // 开发者_Go百科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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜