0

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?

1
  • I don't think there is any way to avoid MSDTC in this case.
    – Ron Jacobs
    Dec 9, 2011 at 19:17

2 Answers 2

1

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

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.