在 WF4 中工作流定义更改后加载持久工作流

发布于 2024-08-18 00:59:12 字数 492 浏览 6 评论 0原文

如何解决这个问题(在 WF4 中):

我在 xaml 中创建一个工作流并启动它的多个实例,我有一个持久性存储,并且所有工作流都保留在其工作流一半的书签上。

现在我停止应用程序

如果我重新启动应用程序,一切都会恢复,并且很好地完成。

但是,如果我想在运行实例持续存在后更改工作流定义怎么办?加载正在运行的工作流(我能够找到)的唯一方法是以下方式:

        WorkflowApplication wfapp = new WorkflowApplication(new WorkflowDefinition());
        wfapp.InstanceStore = new SqlWorkflowInstanceStore(connStr);

        wfapp.Load(wfGuid);

所以您需要工作流定义,如果它在持久性期间发生了变化,事情就会变得非常错误。

解决这个问题的最佳方法是什么?

How to solve this problem (in WF4):

I create a workflow in xaml and start several instances of it, I have a persistancestore and all workflows persist on a bookmark half way their workflow.

Now I stop the application

If I restart te application everything is resumed, en nicely completes.

But what if I want to change the workflow definition after the running instances persist? the only way to load the running workflows (that I was able to find) is the following way:

        WorkflowApplication wfapp = new WorkflowApplication(new WorkflowDefinition());
        wfapp.InstanceStore = new SqlWorkflowInstanceStore(connStr);

        wfapp.Load(wfGuid);

So you need the workflow definition, if it has changed during the persistance, things go horribly wrong.

What is the best way to solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

舞袖。长 2024-08-25 00:59:12

这个场景有点问题。无法将旧的工作流定义迁移到新格式。我已经做了一些有限的测试和一些添加/删除活动的场景,但尚未执行的情况很好。但我也遇到过严重错误的情况,包括重新执行已经完成的活动。

据我所知,除了跟踪用于创建工作流的 XAML/程序集的版本并检查何时要重新启动工作流以确定要使用的工作流版本之外,没有什么好的方法可以解决该问题。

This scenario is a bit of a problem. There is no way to migrate am older workflow definition to the new format. I have done some limited testing and some scenarios with adding/deleting activities that where not yet executing worked fine. But then I also has scenarios go badly wrong, including re executing an already finished activity.

As far as I am aware there is no good way to solve the problem other than tracking the version of the XAML/assembly used to create the workflow and checking that when you want to restart a workflow to determine the workflow version to use.

笨笨の傻瓜 2024-08-25 00:59:12

同一工作流程的许多版本必须共存。我的意思是,旧实例必须以旧工作流程版本结束,新实例必须以新工作流程版本开始。
就我而言,我们有工作流程服务。在配置中,路由器描述了实例尝试执行的顺序。如果实例无法开始使用一个版本,则会尝试下一个版本,依此类推。

此外,如果您的更改不涉及工作流变量、公开的合同等的更改...旧的和新的工作流实例版本可以在同一工作流版本上运行。你测试一下就知道了。

Many versions of the same workflow has to coexist. I mean, the old instances has to finish with the old workflow version, and the new ones has to begining with new workflow version.
In my case, we have workflow services. It's on configuration where a router describe the order in which instances try to be executed. If an instance cannot start working with one version, the next one is tried, and so on.

Also, if your change doesn't involve changes in workflow variables, contracts exposed, etc... old and new workflow instance versions can run on the same workflow version. You'll know that, testing it.

那片花海 2024-08-25 00:59:12

这与其说是Windows Workflow 的问题,不如说是SQL 持久性服务的问题。您可以创建自己的持久性服务来处理这种情况,方法是支持将旧工作流转换为新工作流或更抽象的东西,例如序列化为 XML/JSON 的持久性服务,这种服务可能更容易支持反序列化版本作为另一个版本。

It's not so much an issue with Windows Workflow as it is the SQL persistence service. You could create your own persistence service that can handle this situation, either by supporting conversion of the old workflow into the new workflow or something more abstract, like a persistence service that serializes as XML/JSON, something that might more easily support deserialization of one version as another version.

岁月染过的梦 2024-08-25 00:59:12

在更改 WF4 中的定义后,可以加载持久的 wf 实例 - 您必须解析并更改 wf 引擎存储的 xml 文件。您应该创建两个相同的工作流程:使用旧版本和新版本并比较它们以消除差异。必须对定义 xml 和用于存储工作流状态的复杂数据 xml 执行此操作。使用 LinqToXML 解析它会节省您大量时间,并且您必须确保已检查所有差异 - 如果剩下一处差异,wf 将无法加载。
您可以在 wf state xml 中找到一个元素“ResumeData”,该元素太重而无法解析,但好消息是您可以简单地将其删除。

It is possible to load persisted wf instance after changing the definition in WF4 - you have to parse and change the xml files that the wf engine stores. You should create two equal workflows : with the old version and the new version and to compare them in order to remove the differences. This must be done for the definition xml and the complex data xml that is used to store the workflow state. Parsing it with LinqToXML will save you lots of time and you have to be sure that you have checked all the differences - if there is one difference left, the wf will not be able to Load.
There is one element "ResumeData", which you could find in the wf state xml, which is too heavy to parse, but the good news is that you can simply remove it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文