[英]Workflow persistence and bookmarks as a workflow failover
I have set of custom activities, which are used in complex workflows. 我有一组自定义活动,用于复杂的工作流程。
I would like to make them (custom activities) persistable without having workflow in an idle state. 我想让它们(自定义活动)保持不变,而不需要工作流处于空闲状态。 It should be kind of failover system, so whenever something goes wrong during execution of a workflow it can be either:
它应该是一种故障转移系统,因此在执行工作流时出现问题时,它可以是:
I've worked for few days with workflow persistance, but I am not sure if I can achieve my goal with it. 我已经工作了几天工作流程持久性,但我不确定我是否可以实现我的目标。 Why?
为什么?
Can you please advice me, it workflow bookmarks are the way to go here? 你可以请教我,它的工作流程书签是去哪里的?
I see some light in notblocking bookmarks, but I cannot persist them and resume later on. 我看到一些没有阻止书签的亮点,但我不能坚持下去并稍后恢复。 Can you please give me some hints how to persist a nonblocking bookmark for later resume?
你能不能给我一些提示,告诉我如何为以后的简历保留一个非阻塞书签?
Edit: 编辑:
In wf3 there was an attribute PersistOnClose
which would be enough for my requirement. 在wf3中有一个属性
PersistOnClose
,这足以满足我的要求。 in wf4 it was replaced with Persist
activity, which could also be useful, however I do not want to have extra activities in my already complex workflows. 在wf4中,它被
Persist
活动取代,这也很有用,但是我不希望在我已经很复杂的工作流程中有额外的活动。
Ideally, it would be great to be able to execute context.RequestPersist(callback)
from NativeActivityContext
, however this method is internal (and everything what is inside it is not visible outside of original assembly. 理想情况下,能够从
NativeActivityContext
执行context.RequestPersist(callback)
会很棒,但是这个方法是内部的(并且其中的所有内容在原始程序集之外是不可见的。
Here is what I came with: 这是我的意思:
PersistOnCloseAttribute
is not an option, because I'm using WF4 and this attribute is only .NET 3.x WF. PersistOnCloseAttribute
不是一个选项,因为我使用的是WF4,这个属性只有.NET 3.x WF。 The solution is to use Persist
activity in each custom made activity (has to extend NativeActivity
which can schedule child activities): 解决方案是在每个自定义活动中使用
Persist
活动(必须扩展可以安排子活动的NativeActivity
):
//class field
Activity childActivity = new Persist();
In order to make it work, it has to be added to metadata as ImplmentationChild: 为了使其工作,必须将其作为ImplmentationChild添加到元数据中:
protected override void CacheMetadata(NativeActivityMetadata metadata)
{
base.CacheMetadata(metadata);
metadata.AddImplementationChild(this.childActivity);
}
The last thing is to schedule child activity from Execute method (doesn't matter where, persistence will happen only after calling activity is completed*). 最后一件事是从Execute方法安排子活动(无论何处,只有在调用活动完成后才会发生持久性*)。
protected override void Execute(NativeActivityContext context)
{
//...
context.ScheduleActivity((Activity)this.childActivity);
}
In order keep the workflow persisted after unhandled exception, this piece of code have to be added to WorkflowApplication: 为了在未处理的异常之后保持工作流程保持不变,必须将这段代码添加到WorkflowApplication:
application.OnUnhandledException = delegate(WorkflowApplicationUnhandledExceptionEventArgs e)
{
return UnhandledExceptionAction.Abort;
};
*return from the Execute
method doesn't necessarily mean that the activity is "completed" - ie there are blocking bookmarks inside activity (see drawbacks below). *从
Execute
方法返回并不一定意味着活动已“完成” - 即活动内部存在阻止书签(请参阅下面的缺点)。
There are few drawbacks of this solution: 这个解决方案有一些缺点:
If i understand you question correctly then, you have below requirements. 如果我理解你的问题,那么你有以下要求。
You can approach using below steps. 您可以使用以下步骤。
in case of any issue and customization required discussed same.:) as I have developed workflow like similar like yours. 如果有任何问题和定制需要讨论相同。:)因为我已经开发了类似你的工作流程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.