I've been working with some ExternalDataExchange - based communication in WF recently. My understanding is that when working with a long-running (in this case, a State Machine) workflows, communication is queued, durable, and transactional.
I'm using SQL Persistence and a EventArgs that is marked as "WaitForIdle = true".
I would assume that when I do something like this:
using(TransactionScope scope = new TransactionScope())
{
IMyEDEService service = wfRuntime.GetService<IMyEDEService>()
service.MyMethod(wfInstanceGuid, "Here's some data");
DoSomeDatabaseWork();
} //Dispose causes scope to rollback
I would expect that my event won't fire on the workflow. It appears to actually be delivered, though, so this leads me to believe this is not transactional. You could see how the data committed to a database in DoSomeDatabaseWork() being rolled back, but the workflow moving foward could be bad.
Can anyone confirm this and if so, do you have a workaround to make the message a transactional one?
Really what I want is one of these two things:
- The workflow shouldn't react to the message I enqueued via external data exchange until the transaction that enqueued the message is committed (much like service broker does in SQL server).
--or--
- If the workflow does start acting on the event I delivered, it should rollback as well. I don't see how this could occur using the default scheduler, though. I'd like the workflow execution to remain asynchronous, so I don't want to switch out the scheduler if I don't have to.