为什么业务对象通过工作流进行序列化?

发布于 2024-11-17 13:51:16 字数 314 浏览 2 评论 0原文

当您有一个需要持久性的长时间运行的工作流时,似乎唯一的解决方案是让工作流框架在存储之前序列化该工作流和业务对象。

这是否会导致给定业务对象的多个副本可能会不同步?

您如何处理同步问题以及为什么要使用工作流序列化业务对象(而不是维护工作流和业务对象之间的链接)?

我发现了一个相关问题,但它并没有真正回答如何处理它或者为什么你想这样做。

When you have a long-running workflow that requires persistence, it seems like the only solution is to have the workflow framework serialize that workflow AND the business objects before storing them.

Wouldn't this result in multiple copies of a given business object that could grow out of sync?

How do you handle the synchronization issues and why would you want to serialize the business object with the workflow (vs. maintaining a link between the workflow and the business object)?

I found a related question but it doesn't really answer how to handle it or why you would want to do this.

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

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

发布评论

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

评论(1

遥远的绿洲 2024-11-24 13:51:16

<块引用>

当您有一个需要持久性的长时间运行的工作流时,似乎唯一的解决方案是让工作流框架在存储之前序列化该工作流和业务对象。

是的。序列化允许数据无限期地保存在单个独立的结构中。

<块引用>

这是否会导致给定业务对象的多个副本可能会变得不同步?

如果代码的设计假设副作用会以某种方式神奇地传播,那么是的。所以不要这样做:-)

<块引用>

如何处理同步问题以及为什么要使用工作流序列化业务对象(而不是维护工作流和业务对象之间的链接)?

这取决于。

例如,在 SharePoint 环境中,人们可能只保留列表 Guid 和项目 Id(这些是通过工作流序列化的),然后按需检索项目。也就是说,SharePoint 列表项充当“业务对象”,其在工作流之外具有生命周期(时间)。因为 Item 是一个共享外部资源,所以除了有趣的小竞争条件之外,它是“同步的”。

什么时候不应该有“链接”?好吧,当不需要这样的同步时——例如,初始值在工作流的持续时间内有效和/或不可变。这两种方法可以混合使用,这实际上取决于业务逻辑要求。

快乐编码。

When you have a long-running workflow that requires persistence, it seems like the only solution is to have the workflow framework serialize that workflow AND the business objects before storing them.

Yes. Serialization allows the data to be persisted indefinitely in a single self-contained structure.

Wouldn't this result in multiple copies of a given business object that could grow out of sync?

If code was designed with assumption that side-effects will somehow magically propagate, then yes. So don't do that :-)

How do you handle the synchronization issues and why would you want to serialize the business object with the workflow (vs. maintaining a link between the workflow and the business object)?

This depends.

For instance, in a SharePoint environment, one may only keep the List Guid and Item Id (these are serialized with the Workflow) and then retrieve the Item on demand. That is, the SharePoint list Item serves as the "business object" which has a life(time) outside the Workflow. Because the Item is a shared external resource then, barring fun little race conditions, it is "in sync".

When to not have "a link"? Well, when no such synchronization is required -- e.g. the initial values are valid for the duration of the Workflow and/or immutable. Both methods can be employed together in a hybrid and it really depends upon the business logic requirements.

Happy coding.

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