locked
Host a non-service workflow in IIS - With Distributed Transactions Enabled RRS feed

  • Question

  • Hi

    I am trying use the technique described in http://msdn.microsoft.com/en-us/library/ff729688.aspx. With the addition of calling the endpoint with transactions enabled. This will allow me to roll back any changes in my local database if the workflow creation fails.

    To that end I have removed the "IsOneWay=true" from the contract and send back a response in the implemenation. I have also enabled TransactionFlow in my client and server bindings. Finally I have wrapped my local database work and the call to start the workflow in a TransactionScope.

    Everything seems to work ok up to the point that I leave the WCF service(which contains the transaction scoped unit of work) at which point I get the following exception.

    Exception: System.Runtime.CallbackException: Async Callback threw an exception. ---> System.Runtime.DurableInstancing.InstancePersistenceCommandException: The execution of the InstancePersistenceCommand named {urn:schemas-microsoft-com:System.Activities.Persistence/command}SaveWorkflow was interrupted by an error. ---> System.Data.SqlClient.SqlException: Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.

    at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)

    at System.Activities.DurableInstancing.SqlWorkflowInstanceStoreAsyncResult.SqlCommandAsyncResultCallback(IAsyncResult result)

     

    Any help, suggestions, definitive answers will be gratefully received.

    Thanks in advance

    Darren

    Is it possible to what I am trying to do? If it is, where am I going wrong.

    Darren
    Monday, December 6, 2010 3:10 PM

All replies

  • Not sure I would do it this way (not sure why it is failing either).  Why not just create a WorkflowService that uses a TransactedRecevieScope to receive the message?


    http://blogs.msdn.com/rjacobs
    Wednesday, December 8, 2010 1:28 AM
  • Thankyou for the interest Ron.

    Let me explain a little further maybe. The workflows that I am hosting are not WCF (message) based and I am managing/deploying them myself, but want them to exist within IIS. Therefore the only method I have available (I believe) is using the endpoint described in the article on msdn. To that end the fact that NamedPipe binding allows transactional flow would indicate that transactions are permitted across this boundary. And indeed the distributed transaction seems partially work, as seem to be able to rollback ok (I think, could be a red herring).

    What I think is happening is that the SqlWorkflowInstanceStore is making aysnc calls, which are not properly considered in the transaction. The async call is made within a transaction, it carries on and completes as if everything is ok. On async completion the distributed transaction has already completed and that is where my problem lies. This a complete guess. But it may trigger the correct explanation.

    Does this make sense? Is there anything else I can do?

    Regards

    Darren


    Darren
    Wednesday, December 8, 2010 11:20 AM
  • HI, Darren

    ->"Therefore the only method I have available (I believe) is using the endpoint described in the article on msdn. "
    This isn't the only method. You can also create a ASP.NET page or even a pure HttpHandler to host the WF4 workflow.

    ->"System.Data.SqlClient.SqlException: Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction."
    Do you get the same error if you host you workflow in a Console Application? if not, the error could be due to your WCF service design, and you may want to consider use ASP.NET or HttpHandler as the workflow host.

    Hope this helps
    Regards
    MSDN Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    This posting is provided "AS IS" with no warranties, and confers no rights. My Blog: http://xhinker.com
    Microsoft Windows Workflow Foundation 4.0 Cookbook
    Monday, December 13, 2010 8:36 AM