使用自托管 WorkflowServiceHost 重新启动持久工作流程
我正在尝试弄清楚如何恢复我使用 WorkflowServiceHost 自托管的持久工作流程。目前,我的主机将持久性和空闲行为连接起来,如下所示:
// 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);
我将工作流实例 GUID 与工作流中包含的自定义活动内的数据库中的 ProductID 存储在一起,因此我能够轻松地将特定工作流实例跟踪到产品 ID。我希望能够以某种方式将此产品 ID 传递给我的 ServiceHost,并让它为我恢复正确的持久工作流程。
谁能指出我如何做到这一点的正确方向?
预先非常感谢 伊恩
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要阅读内容关联。您将把您的 ProductID 与您的接收活动相关联。当您到达接收时,将创建一个书签,并且您的工作流程将被保留。您调用接收并传入您的 ProductID,并且由于相关性,WF 运行时知道要恢复哪个实例。
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.