Leonardo
Leonardo

Reputation: 11401

Workflow Foundation and DTC transaction Rollback misbehavior

I'm testing the receive transaction scope in workflow foundation 4.5 and i think that there's something wrong with it!

See when I roolback a transaction either by explicit roolback:

using (TransactionScope s = new TransactionScope())
{
    using (ServiceReference1.ServiceClient cli = new ServiceReference1.ServiceClient())
    {
        Transaction t = Transaction.Current;                    
        cli.GetData(new ServiceReference1.GetData() { data = 10, ID = id });
        t.Rollback();                                        
    }
}

or by throwing an exception in the transactionScope:

using (TransactionScope s = new TransactionScope())
{
    using (ServiceReference1.ServiceClient cli = new ServiceReference1.ServiceClient())
    {
        cli.GetData(new ServiceReference1.GetData() { data = 10, ID = id });
        throw new Exception("Error!");
    }
}

I expect the workflow to be rolledback too! In another words, i expect that the receive "GetData" is still valid! but that does not happen. The workflow is executed and GetData is no longer a valid!

There are others "receives" after the "GetData" to guarantee that the workflow won't enter the "completed" state...

I'm sure that my transaction is flowing into the workflow because inside the workflow i have a activity that returns me the transaction ID (which of course matches the ones on the app)

Can anyone tell what is going on? what i'm missing?

Futher notes:
Everything is running in my machine (including the backing store, on Sql Server 2012) DTC is enabled

Upvotes: 0

Views: 456

Answers (1)

Maurice
Maurice

Reputation: 27632

A workflow itself is not a transactional resource. So while any database updates you have done might be rolled back the state of the workflow itself isn't reset.

Upvotes: 0

Related Questions