have you thought about how errors could be handled with your Pipeline. Imagine if there was so unexpected error for some reason. Currently, the pipeline would just terminate nicely. It's simple to handle a WorkflowTerminated event .. but i'm curious to
see how you can intergrate that into your MVC app .. or should i be more specific, your controller action method. Especically when you invoke the workflow instance, it runs off asyncronously .. so if u DO bubble up some errors (eg. UI validation error or logic
error, which you want to then display to the UI) .. the mvc controller action method has already continued on and completed.
thoughts?
:: Never underestimate the predictability of stupidity ::
I've found the answer to having the WF run asyncronously in ASP.NET.
this link here describes a way, but they are putting the runtime into the Application state, which doesn't apply to the starter kit because the WF is in it's own project.
What needs to be added to the runtime is a manual service. The default one is an async one.
here's some code.
public static WorkflowRuntime WFRuntimeInstance
{ get
{ lock (padlock)
{ if (WFRuntime == null)
{
WFRuntime = new WorkflowRuntime();
WFRuntime.AddService(new ManualWorkflowSchedulerService());
WFRuntime.StartRuntime();
} return WFRuntime;
}
}
}
... ...
ManualWorkflowSchedulerService manualScheduler =
WFRuntimeInstance.GetService(typeof (ManualWorkflowSchedulerService))
as ManualWorkflowSchedulerService; if (manualScheduler == null)
{ throw new InvalidOperationException("Unable to retrieve the manual workflow scheduler service.");
}
Notice how on the creation of the static object, we add the Manual service. Then, when we start the workflow, we also run the manual scheduler's workflow.
Now .. to figure out how to capture any exceptions that were thrown in the WF, and bubble them back up to the controller ... *hint hint* :)
:: Never underestimate the predictability of stupidity ::
pure.krome
Member
532 Points
349 Posts
How to handle errors in your Windows Work Flow pipelines?
Nov 13, 2008 11:29 PM|LINK
Hi Rob,
have you thought about how errors could be handled with your Pipeline. Imagine if there was so unexpected error for some reason. Currently, the pipeline would just terminate nicely. It's simple to handle a WorkflowTerminated event .. but i'm curious to see how you can intergrate that into your MVC app .. or should i be more specific, your controller action method. Especically when you invoke the workflow instance, it runs off asyncronously .. so if u DO bubble up some errors (eg. UI validation error or logic error, which you want to then display to the UI) .. the mvc controller action method has already continued on and completed.
thoughts?
pure.krome
Member
532 Points
349 Posts
Re: How to handle errors in your Windows Work Flow pipelines?
Nov 20, 2008 09:33 AM|LINK
I've found the answer to having the WF run asyncronously in ASP.NET.
this link here describes a way, but they are putting the runtime into the Application state, which doesn't apply to the starter kit because the WF is in it's own project.
What needs to be added to the runtime is a manual service. The default one is an async one.
here's some code.
public static WorkflowRuntime WFRuntimeInstance
{
get
{
lock (padlock)
{
if (WFRuntime == null)
{
WFRuntime = new WorkflowRuntime();
WFRuntime.AddService(new ManualWorkflowSchedulerService());
WFRuntime.StartRuntime();
}
return WFRuntime;
}
}
}
... ...
ManualWorkflowSchedulerService manualScheduler =
WFRuntimeInstance.GetService(typeof (ManualWorkflowSchedulerService)) as ManualWorkflowSchedulerService;
if (manualScheduler == null)
{
throw new InvalidOperationException("Unable to retrieve the manual workflow scheduler service.");
}
WorkflowInstance instance = WFRuntimeInstance.CreateWorkflow(typeof(AddPostWorkflow),
parameters);
instance.WorkflowRuntime.WorkflowTerminated += WorkflowRuntime_WorkflowTerminated;
instance.Start();
manualScheduler.RunWorkflow(instance.InstanceId);
Notice how on the creation of the static object, we add the Manual service. Then, when we start the workflow, we also run the manual scheduler's workflow.
Now .. to figure out how to capture any exceptions that were thrown in the WF, and bubble them back up to the controller ... *hint hint* :)
pure.krome
Member
532 Points
349 Posts
Re: How to handle errors in your Windows Work Flow pipelines?
Nov 21, 2008 01:38 AM|LINK
Please excuse my one person conversation here :) ... but i've figure out how to bubble up exceptions that occur in the workflows, to the controller.
I've uploaded a patch to http://www.codeplex.com/mvcsamples/SourceControl/PatchList.aspx
It includes
a) manual scheduler service
b) handling trapping any exceptions thrown in the workflow.
awesome!
hth Rob :)