workflow-core
workflow-core copied to clipboard
How to retry a workflow, of which one step failed?
Occasionally, a step may fail because of network connectivity or any issue. I do not see anywhere in the docs a possibility to restart the workflow from the step it failed during its previous run.
Resume workflow only resumes previously suspended workflows.
You can configure a step to have retry behavior - https://workflow-core.readthedocs.io/en/latest/error-handling/
Maybe I was not clear enough in my question. What I meant was, How can I resume a previous failed workflow, on a later time, on demand. e.g step 5 of a 10 step workflow failed due to remote server issues. Remote server is fixed 2 hours later, Resume previously failed workflow, starting from failed step.
Similar logic to a Suspended workflow, only this one has failed and the step that has failed, needs to re-run
Should you be terminating the workflow if you intend to retry it later?
How would you suggest to handle this?
You can set the default error behavior per workflow.
public void Build(IWorkflowBuilder<object> builder)
{
builder
.UseDefaultErrorBehavior(WorkflowErrorHandling.Suspend)
.StartWith<HelloWorld>()
.Then<GoodbyeWorld>();
}
or per step
public void Build(IWorkflowBuilder<object> builder)
{
builder
.StartWith<HelloWorld>()
.Then<GoodbyeWorld>()
.OnError(WorkflowErrorHandling.Suspend);
}
This is mostly working so far, but quite often, some workflows, even though they are set to suspend on error, they actually fail instead.