在WF4.0中使用PersistenceIOParticipant时如何避免DTC?

发布于 2024-12-20 07:09:37 字数 126 浏览 0 评论 0原文

我正在 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 技术交流群。

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

发布评论

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

评论(2

幽梦紫曦~ 2024-12-27 07:09:37

我发现 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

躲猫猫 2024-12-27 07:09:37

如果使用 SQL Server 2008+,那么是否需要多个连接应该没有关系。在 SqlWorkflowInstanceStore 上使用反射器后,我发现它在连接字符串上设置了一些附加属性。以下是它用于创建连接字符串的代码:

  SqlConnectionStringBuilder builder2 = new SqlConnectionStringBuilder(connectionString);
  builder2.AsynchronousProcessing = true;
  builder2.ConnectTimeout = (int)TimeSpan.FromSeconds(15.0).TotalSeconds;
  builder2.ApplicationName = "DefaultPool";
  SqlConnectionStringBuilder builder = builder2;
  return builder.ToString();

我使用探查器验证了在使用自定义 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:

  SqlConnectionStringBuilder builder2 = new SqlConnectionStringBuilder(connectionString);
  builder2.AsynchronousProcessing = true;
  builder2.ConnectTimeout = (int)TimeSpan.FromSeconds(15.0).TotalSeconds;
  builder2.ApplicationName = "DefaultPool";
  SqlConnectionStringBuilder builder = builder2;
  return builder.ToString();

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.

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