-
Notifications
You must be signed in to change notification settings - Fork 2
Part 4 Error handling
Gurmit Teotia edited this page Jun 20, 2019
·
8 revisions
Guflow reports errors using two styles- events and exceptions. You can read more about error handling in wiki.
In this part of the tutorial, we will handle the error events in the workflow. We will configure the workflow to
- Reschedule DownloadActivity on failure.
- Restart the workflow if TranscodeActivity or UploadToS3Activity have timed out
[WorkflowDescription("1.0")]
public class TranscodeWorkflow : WorkflowDescription
{
public TranscodeWorkflow()
{
//Reschedule the DownloadActivity after 2 seconds. Maximum retry attempt is limited to 3.
ScheduleActivity<DownloadActivity>()
.OnFailure(a=>Reschedule(a).After(Timespan.FromSeconds(2)).UpTo(Limit.Count(3));
//Restart the workflow if the activity has timed. Very useful to provide elastic behaviour.
ScheduleActivity<TranscodeActivity>().AfterActivity<DownloadFile>()
.OnTaskList(a=>a.Parent().Result().PollingQueue)
.WithInput(a=> new { InputFile=a.Parent().Result().DownloadedFile, Format ="MP4"});
.OnTimeout(a=>RestartWorkflow());
//Restart the workflow if the activity has timed. Very useful to provide elastic behaviour.
ScheduleActivity<UploadToS3Activity>().AfterActivity<TranscodeActivity>()
.OnTaskList(_=>Activity<DownloadActivity>().Result().PollingQueue)
.WithInput(a=> new { InputFile=a.Parent().Result().TranscodedFile});
.OnTimeout(a=>RestartWorkflow());
//SendConfirmationActivity can be executed on any worker machine
ScheduleActivity<SendConfirmationActivity>().AfterActivity<UploadToS3Activity>();
}
}
You can see the complete source code for this tutorial at github.
I hope this tutorial has given you a head start in Guflow library. You can read the more details documents in wiki
Guflow
- Prerequisite
- Installation
-
Workflows
- Creating first workflow
- Registration
- Hosting
- Start workflow
- Schedule activities
- Schedule timers
- Schedule lambda function
- Schedule child workflows
- Lambda functions vs activities
- Workflow input
- Workflow actions
- Signals
- Workflow branches
- Deflow algorithm
- Workflow events
- Query APIs
- Custom polling strategy
- Things to take care of
- Activites
- Unit testing
- Performance & scalability
- Error handling
- Logging
- Debugging
- Tutorial
- Release notes