Tuesday, August 08, 2006

WF, ASP.NET, and transactions

My current project has some pretty simple business logic that seemed like it would be a good fit for WF. I was looking for a good excuse to try it out for real so I started investigating using it and immediately ran into several key problems.

The first is that there aren't many samples available relating to using WF with an ASP.NET host. Some of this is because it's still beta, but the only ASP.NET stuff available is either hopelessly trivial (start a workflow on a button click and then wait for it to finish before returning) or just not analogous to a real situation (no error handling, transactions, etc.). Additionally, you have to use a manual scheduler as opposed to the default one. I'm trying to get WF to replace business logic, so it would live in the service layer. I'd need extra code there to check whether we were running with the manual scheduler or not (in order to call RunWorkflow if necessary), which seems gross.

The other big issue is that it doesn't seem possible to have workflows participate in a transaction that is initiated by the host. My scenario involves keeping track of many running instances that all need to be finished and exported at once. This would involve iterating over each instance, sending it a specific event, and then, once all instances have been notified, running a stored proc (or something) once to do the export. All of that needs to be in one transaction, but it appears this isn't possible.

I might have to not use WF for this scenario if I can't find answers to those questions. I'm also concerned that if there aren't good answers, it may severely limit the applicability of WF.

No comments: