在WF4.0中使用PersistenceIOParticipant时如何避免DTC?
我正在 WF4.0 中使用 PersistenceIOParticipant 将某些内容与工作流实例的持久性一起保存到数据库中。我不知道如何将相同的连接对象与工作流持久性一起使用,并且我被迫使用分布式事务。有什么方法可以避免使用 DTC?
I am using PersistenceIOParticipant in WF4.0 to save something into database together with the persistence of the workflow instance. I have no idea that how to use the same connection object with the workflow persistence and I am forced to use the distributed transaction. Are there any ways to avoid using DTC?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现 WF4 示例项目“WorkflowApplication ReadLine Host”很有用
查看操作中 persistenceIOParticipant 的示例。
我切换了构造函数中的布尔值以验证是否正在使用事务并且
需要 MSDTC。
请参阅 http://msdn.microsoft.com/en-us/library/dd764467。 ASPX
I found the WF4 Sample project "WorkflowApplication ReadLine Host" useful
to see an example of persistenceIOParticipant in action.
I toggled the booleans in the constructor to verify that a transaction was being used and that
MSDTC was required.
See http://msdn.microsoft.com/en-us/library/dd764467.aspx
如果使用 SQL Server 2008+,那么是否需要多个连接应该没有关系。在 SqlWorkflowInstanceStore 上使用反射器后,我发现它在连接字符串上设置了一些附加属性。以下是它用于创建连接字符串的代码:
我使用探查器验证了在使用自定义 IO 参与者和此连接字符串代码时不涉及 MSDTC。不要忘记将 true 传递给基本 PersistenceIOParticipant 构造函数并适当地传递 Transaction.Current。显然,微软可以随时更改这一点,因此您可以自行决定使用。
If using SQL Server 2008+, then it shouldn't matter if multiple connections are required. After using reflector on the SqlWorkflowInstanceStore, I discovered it was setting some additional properties on the connection string. Here is the code it uses to create a connection string:
I verified with profiler that MSDTC is not involved when using a custom IO participant and this connection string code. Don't forget to pass true to the base PersistenceIOParticipant constructor and flow Transaction.Current appropriately. Obviously, Microsoft could change that at anytime so use at your own discretion.