Workflow Foundation 在内存中存储状态有问题吗?
我们有一位承包商开发了一个使用 .NET 3.5 中的工作流基础的系统。我的一位同事担心“工作流服务在内存中存储状态,它可能与我们的底层数据库不同步”。
他的担忧有道理吗?
We have a contractor who has developed a system that uses the workflow foundation in .NET 3.5. One of my colleagues has concerns "around the workflow service storing state in memory and it possibly becoming out of sync with our underlying database".
Are his concerns justified?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
状态以什么方式存储在内存中?当工作流进入空闲状态时,WF 具有持久性服务。您可以确保 WF 持久保存到您的数据库中。我们在将信息排队到特定工作流程以重新启动 WF 运行时方面没有任何问题 - WF 将从数据库中获取并在正确的位置执行。
好的,
再次重读您可能意味着,如果您将状态存储在工作流中(例如,在活动的依赖属性中),则这可能会变得不同步。这很大程度上取决于它是否可以发生。如果原始数据发生更改,使用数据库数据创建的序列化对象可能会在 WF 中不同步。如果这是一个问题,您可能更想从数据库数据重新创建某些对象,而不是将它们作为序列化对象保留在 WF 中。
In what way is state stored in memory? WF has a persistence service when e.g. the Workflow goes into the idle state. You can ensure that the WF is persisted to your database. We have no issues in e.g. enqueuing info to a specific workflow to restarted WF runtimes - the WF will be picked up from the DB and executed at the correct position.
OK,
rereading once more you could mean that if you store state in the Workflow (e.g. in dependeny properties of an activity) that this could become out of sync. That pretty much depends if it is OK to happen or not. A serialized object that was created with DB data could be out of sync in a WF if the original data changed. If this is a concern you may rather want to recreate certain objects from DB data and not persist them as serialized objects in your WF.
这取决于他是如何做到的,但答案可能是否定的。内存缓存是一种在涉及数据库时避免不必要的 I/O 的有用方法。也许你的同事需要看一下代码才能让自己感觉好一点。
It depends on how he's done it, but the answer is probably no. Memory caching is a useful way to avoid unnecessary I/O when a DB is involved. Perhaps your colleague needs to have a look through the code to make himself feel better.