-
Notifications
You must be signed in to change notification settings - Fork 2
Schedule timers
Gurmit Teotia edited this page Jan 12, 2018
·
7 revisions
In a workflow you can explicitly schedule the timer or you can implicitly use in workflow actions. In a workflow you can explicitly schedule a timer like below:
public class TranscodeWorkflow : Workflow
{
public TranscodeWorkflow()
{
ScheduleTimer(name:"DelayBeforeDownload").FireAfter(TimeSpan.FromSeconds(2));
ScheduleActivity<DownloadActivity>().AfterTimer("DelayBeforeDownload");
}
}
Just like activity, timer will be scheduled in Amazon SWF and it does not rely on your local system time.
In workflow you can also timer implicitly with custom action. Following example clarify it further:
public class TranscodeWorkflow : Workflow
{
public TranscodeWorkflow()
{
//In following example workflow will schedule the timer on failure and when timer is fired after 4 seconds it will
// reschedule the activity
ScheduleActivity<DownloadActivity>().OnFailure(e=>Reschedule(e).After(TimeSpan.FromSeconds(4));
}
}
ScheduleTimer api will let you react different based on conditions. e.g. when the timer is fired it will schedule its child items but you can change it to behave differently.
public class TranscodeWorkflow : Workflow
{
public TranscodeWorkflow()
{
ScheduleTimer(name:"DelayBeforeDownload").FireAfter(TimeSpan.FromSeconds(2))
.OnFired(a=>CompleteWorkflow("result"));
}
}
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