Menu
Amazon Simple Workflow Service
Developer Guide (API Version 2012-01-25)

Life Cycle of an Amazon SWF Workflow Execution

From the start of a workflow execution to its completion, Amazon SWF interacts with actors by assigning them appropriate tasks, either activity tasks or decision tasks.

The following diagram shows the life cycle of an order-processing workflow execution from the perspective of components that act on it.


            Ecommerce workflow execution

The following table explains each task in the preceding image.

Workflow Execution Life Cycle

Description

Action, Decision, or Event

1) The workflow starter calls the appropriate Amazon SWF action to start the workflow execution for an order, providing the order information.

StartWorkflowExecution action.

2) Amazon SWF receives the start workflow execution request and then schedules the first decision task.

WorkflowExecutionStarted event and DecisionTaskScheduled event.

3) The decider receives the task from Amazon SWF, reviews the history, applies the coordination logic to determine that no previous activities occurred, makes a decision to schedule the Verify Order activity with the information the activity worker needs to process the task, and returns the decision to Amazon SWF.

PollForDecisionTask action. RespondDecisionTaskCompleted action with ScheduleActivityTask decision.

4) Amazon SWF receives the decision, schedules the Verify Order activity task, and waits for the activity task to complete or time out.

ActivityTaskScheduled event.

5) An activity worker that can perform the Verify Order activity receives the task, performs it, and returns the results to Amazon SWF.

PollForActivityTask action and RespondActivityTaskCompleted action.

6) Amazon SWF receives the results of the Verify Order activity, adds them to the workflow history, and schedules a decision task.

ActivityTaskCompleted event and DecisionTaskScheduled event.

7) The decider receives the task from Amazon SWF, reviews the history, applies the coordination logic, makes a decision to schedule a ChargeCreditCard activity task with the information the activity worker needs to process the task, and returns the decision to Amazon SWF.

PollForDecisionTask action. RespondDecisionTaskCompleted action with ScheduleActivityTask decision.

8) Amazon SWF receives the decision, schedules the ChargeCreditCard activity task, and waits for it to complete or time out.

DecisionTaskCompleted event and ActivityTaskScheduled event.

9) An activity worker that can perform the ChargeCreditCard activity receives the task, performs it, and returns the results to Amazon SWF.

PollForActivityTask and RespondActivityTaskCompleted action.

10) Amazon SWF receives the results of the ChargeCreditCard activity task, adds them to the workflow history, and schedules a decision task.

ActivityTaskCompleted event and DecisionTaskScheduled event.

11) The decider receives the task from Amazon SWF, reviews the history, applies the coordination logic, makes a decision to schedule a ShipOrder activity task with the information the activity worker needs to perform the task, and returns the decision to Amazon SWF.

PollForDecisionTask action. RespondDecisionTaskCompleted with ScheduleActivityTask decision.

12) Amazon SWF receives the decision, schedules a ShipOrder activity task, and waits for it to complete or time out.

DecisionTaskCompleted event and ActivityTaskScheduled event.

13) An activity worker that can perform the ShipOrder activity receives the task, performs it, and returns the results to Amazon SWF.

PollForActivityTask action and RespondActivityTaskCompleted action.

14) Amazon SWF receives the results of the ShipOrder activity task, adds them to the workflow history, and schedules a decision task.

ActivityTaskCompleted event and DecisionTaskScheduled event.

15) The decider receives the task from Amazon SWF, reviews the history, applies the coordination logic, makes a decision to schedule a RecordCompletion activity task with the information the activity worker needs to perform the task, and returns the decision to Amazon SWF.

PollForDecisionTask action. RespondDecisionTaskCompleted action with ScheduleActivityTask decision.

16) Amazon SWF receives the decision, schedules a RecordCompletion activity task, and waits for it to complete or time out.

DecisionTaskCompleted event and ActivityTaskScheduled event.

17) An activity worker that can perform the RecordCompletion activity receives the task, performs it, and returns the results to Amazon SWF.

PollForActivityTask action and RespondActivityTaskCompleted action.

18) Amazon SWF receives the results of the RecordCompletion activity task, adds them to the workflow history, and schedules a decision task.

ActivityTaskCompleted event and DecisionTaskScheduled event.

19) The decider receives the task from Amazon SWF, reviews the history, applies the coordination logic, makes a decision to close the workflow execution and returns the decision along with any results to Amazon SWF.

PollForDecisionTask action. RespondDecisionTaskCompleted action with CompleteWorkflowExecution decision

20) Amazon SWF closes the workflow execution and archives the history for future reference.

WorkflowExecutionCompleted event.