为什么业务对象通过工作流进行序列化?
当您有一个需要持久性的长时间运行的工作流时,似乎唯一的解决方案是让工作流框架在存储之前序列化该工作流和业务对象。
这是否会导致给定业务对象的多个副本可能会不同步?
您如何处理同步问题以及为什么要使用工作流序列化业务对象(而不是维护工作流和业务对象之间的链接)?
我发现了一个相关问题,但它并没有真正回答如何处理它或者为什么你想这样做。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的。序列化允许数据无限期地保存在单个独立的结构中。
如果代码的设计假设副作用会以某种方式神奇地传播,那么是的。所以不要这样做:-)
这取决于。
例如,在 SharePoint 环境中,人们可能只保留列表 Guid 和项目 Id(这些是通过工作流序列化的),然后按需检索项目。也就是说,SharePoint 列表项充当“业务对象”,其在工作流之外具有生命周期(时间)。因为 Item 是一个共享外部资源,所以除了有趣的小竞争条件之外,它是“同步的”。
什么时候不应该有“链接”?好吧,当不需要这样的同步时——例如,初始值在工作流的持续时间内有效和/或不可变。这两种方法可以混合使用,这实际上取决于业务逻辑要求。
快乐编码。
Yes. Serialization allows the data to be persisted indefinitely in a single self-contained structure.
If code was designed with assumption that side-effects will somehow magically propagate, then yes. So don't do that :-)
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.