SWF.Client.
respond_decision_task_completed
(**kwargs)¶Used by deciders to tell the service that the DecisionTask identified by the taskToken
has successfully completed. The decisions
argument specifies the list of decisions made while processing the task.
A DecisionTaskCompleted
event is added to the workflow history. The executionContext
specified is attached to the event in the workflow execution history.
Access Control
If an IAM policy grants permission to use RespondDecisionTaskCompleted
, it can express permissions for the list of decisions in the decisions
parameter. Each of the decisions has one or more parameters, much like a regular API call. To allow for policies to be as readable as possible, you can express permissions on decisions as if they were actual API calls, including applying conditions to some parameters. For more information, see Using IAM to Manage Access to Amazon SWF Workflows in the Amazon SWF Developer Guide .
See also: AWS API Documentation
Request Syntax
response = client.respond_decision_task_completed(
taskToken='string',
decisions=[
{
'decisionType': 'ScheduleActivityTask'|'RequestCancelActivityTask'|'CompleteWorkflowExecution'|'FailWorkflowExecution'|'CancelWorkflowExecution'|'ContinueAsNewWorkflowExecution'|'RecordMarker'|'StartTimer'|'CancelTimer'|'SignalExternalWorkflowExecution'|'RequestCancelExternalWorkflowExecution'|'StartChildWorkflowExecution'|'ScheduleLambdaFunction',
'scheduleActivityTaskDecisionAttributes': {
'activityType': {
'name': 'string',
'version': 'string'
},
'activityId': 'string',
'control': 'string',
'input': 'string',
'scheduleToCloseTimeout': 'string',
'taskList': {
'name': 'string'
},
'taskPriority': 'string',
'scheduleToStartTimeout': 'string',
'startToCloseTimeout': 'string',
'heartbeatTimeout': 'string'
},
'requestCancelActivityTaskDecisionAttributes': {
'activityId': 'string'
},
'completeWorkflowExecutionDecisionAttributes': {
'result': 'string'
},
'failWorkflowExecutionDecisionAttributes': {
'reason': 'string',
'details': 'string'
},
'cancelWorkflowExecutionDecisionAttributes': {
'details': 'string'
},
'continueAsNewWorkflowExecutionDecisionAttributes': {
'input': 'string',
'executionStartToCloseTimeout': 'string',
'taskList': {
'name': 'string'
},
'taskPriority': 'string',
'taskStartToCloseTimeout': 'string',
'childPolicy': 'TERMINATE'|'REQUEST_CANCEL'|'ABANDON',
'tagList': [
'string',
],
'workflowTypeVersion': 'string',
'lambdaRole': 'string'
},
'recordMarkerDecisionAttributes': {
'markerName': 'string',
'details': 'string'
},
'startTimerDecisionAttributes': {
'timerId': 'string',
'control': 'string',
'startToFireTimeout': 'string'
},
'cancelTimerDecisionAttributes': {
'timerId': 'string'
},
'signalExternalWorkflowExecutionDecisionAttributes': {
'workflowId': 'string',
'runId': 'string',
'signalName': 'string',
'input': 'string',
'control': 'string'
},
'requestCancelExternalWorkflowExecutionDecisionAttributes': {
'workflowId': 'string',
'runId': 'string',
'control': 'string'
},
'startChildWorkflowExecutionDecisionAttributes': {
'workflowType': {
'name': 'string',
'version': 'string'
},
'workflowId': 'string',
'control': 'string',
'input': 'string',
'executionStartToCloseTimeout': 'string',
'taskList': {
'name': 'string'
},
'taskPriority': 'string',
'taskStartToCloseTimeout': 'string',
'childPolicy': 'TERMINATE'|'REQUEST_CANCEL'|'ABANDON',
'tagList': [
'string',
],
'lambdaRole': 'string'
},
'scheduleLambdaFunctionDecisionAttributes': {
'id': 'string',
'name': 'string',
'control': 'string',
'input': 'string',
'startToCloseTimeout': 'string'
}
},
],
executionContext='string'
)
[REQUIRED]
The taskToken
from the DecisionTask.
Warning
taskToken
is generated by the service and should be treated as an opaque value. If the task is passed to another process, its taskToken
must also be passed. This enables it to provide its progress and respond with results.
The list of decisions (possibly empty) made by the decider while processing this decision task. See the docs for the Decision structure for details.
Specifies a decision made by the decider. A decision can be one of these types:
CancelTimer
– Cancels a previously started timer and records a TimerCanceled
event in the history.CancelWorkflowExecution
– Closes the workflow execution and records a WorkflowExecutionCanceled
event in the history.CompleteWorkflowExecution
– Closes the workflow execution and records a WorkflowExecutionCompleted
event in the history .ContinueAsNewWorkflowExecution
– Closes the workflow execution and starts a new workflow execution of the same type using the same workflow ID and a unique run Id. A WorkflowExecutionContinuedAsNew
event is recorded in the history.FailWorkflowExecution
– Closes the workflow execution and records a WorkflowExecutionFailed
event in the history.RecordMarker
– Records a MarkerRecorded
event in the history. Markers can be used for adding custom information in the history for instance to let deciders know that they don't need to look at the history beyond the marker event.RequestCancelActivityTask
– Attempts to cancel a previously scheduled activity task. If the activity task was scheduled but has not been assigned to a worker, then it is canceled. If the activity task was already assigned to a worker, then the worker is informed that cancellation has been requested in the response to RecordActivityTaskHeartbeat.RequestCancelExternalWorkflowExecution
– Requests that a request be made to cancel the specified external workflow execution and records a RequestCancelExternalWorkflowExecutionInitiated
event in the history.ScheduleActivityTask
– Schedules an activity task.SignalExternalWorkflowExecution
– Requests a signal to be delivered to the specified external workflow execution and records a SignalExternalWorkflowExecutionInitiated
event in the history.StartChildWorkflowExecution
– Requests that a child workflow execution be started and records a StartChildWorkflowExecutionInitiated
event in the history. The child workflow execution is a separate workflow execution with its own history.StartTimer
– Starts a timer for this workflow execution and records a TimerStarted
event in the history. This timer fires after the specified delay and record a TimerFired
event.Access Control
If you grant permission to use RespondDecisionTaskCompleted
, you can use IAM policies to express permissions for the list of decisions returned by this action as if they were members of the API. Treating decisions as a pseudo API maintains a uniform conceptual model and helps keep policies readable. For details and example IAM policies, see Using IAM to Manage Access to Amazon SWF Workflows in the Amazon SWF Developer Guide .
Decision Failure
Decisions can fail for several reasons
One of the following events might be added to the history to indicate an error. The event attribute's cause
parameter indicates the cause. If cause
is set to OPERATION_NOT_PERMITTED
, the decision failed because it lacked sufficient permissions. For details and example IAM policies, see Using IAM to Manage Access to Amazon SWF Workflows in the Amazon SWF Developer Guide .
ScheduleActivityTaskFailed
– A ScheduleActivityTask
decision failed. This could happen if the activity type specified in the decision isn't registered, is in a deprecated state, or the decision isn't properly configured.RequestCancelActivityTaskFailed
– A RequestCancelActivityTask
decision failed. This could happen if there is no open activity task with the specified activityId.StartTimerFailed
– A StartTimer
decision failed. This could happen if there is another open timer with the same timerId.CancelTimerFailed
– A CancelTimer
decision failed. This could happen if there is no open timer with the specified timerId.StartChildWorkflowExecutionFailed
– A StartChildWorkflowExecution
decision failed. This could happen if the workflow type specified isn't registered, is deprecated, or the decision isn't properly configured.SignalExternalWorkflowExecutionFailed
– A SignalExternalWorkflowExecution
decision failed. This could happen if the workflowID
specified in the decision was incorrect.RequestCancelExternalWorkflowExecutionFailed
– A RequestCancelExternalWorkflowExecution
decision failed. This could happen if the workflowID
specified in the decision was incorrect.CancelWorkflowExecutionFailed
– A CancelWorkflowExecution
decision failed. This could happen if there is an unhandled decision task pending in the workflow execution.CompleteWorkflowExecutionFailed
– A CompleteWorkflowExecution
decision failed. This could happen if there is an unhandled decision task pending in the workflow execution.ContinueAsNewWorkflowExecutionFailed
– A ContinueAsNewWorkflowExecution
decision failed. This could happen if there is an unhandled decision task pending in the workflow execution or the ContinueAsNewWorkflowExecution decision was not configured correctly.FailWorkflowExecutionFailed
– A FailWorkflowExecution
decision failed. This could happen if there is an unhandled decision task pending in the workflow execution.The preceding error events might occur due to an error in the decider logic, which might put the workflow execution in an unstable state The cause field in the event structure for the error event indicates the cause of the error.
Note
A workflow execution may be closed by the decider by returning one of the following decisions when completing a decision task:CompleteWorkflowExecution
,FailWorkflowExecution
,CancelWorkflowExecution
andContinueAsNewWorkflowExecution
. AnUnhandledDecision
fault is returned if a workflow closing decision is specified and a signal or activity event had been added to the history while the decision task was being performed by the decider. Unlike the above situations which are logic issues, this fault is always possible because of race conditions in a distributed system. The right action here is to call RespondDecisionTaskCompleted without any decisions. This would result in another decision task with these new events included in the history. The decider should handle the new events and may decide to close the workflow execution.
How to Code a Decision
You code a decision by first setting the decision type field to one of the above decision values, and then set the corresponding attributes field shown below:
ScheduleActivityTaskDecisionAttributes
RequestCancelActivityTaskDecisionAttributes
CompleteWorkflowExecutionDecisionAttributes
FailWorkflowExecutionDecisionAttributes
CancelWorkflowExecutionDecisionAttributes
ContinueAsNewWorkflowExecutionDecisionAttributes
RecordMarkerDecisionAttributes
StartTimerDecisionAttributes
CancelTimerDecisionAttributes
SignalExternalWorkflowExecutionDecisionAttributes
RequestCancelExternalWorkflowExecutionDecisionAttributes
StartChildWorkflowExecutionDecisionAttributes
Specifies the type of the decision.
Provides the details of the ScheduleActivityTask
decision. It isn't set for other decision types.
The type of the activity task to schedule.
The name of this activity.
Note
The combination of activity type name and version must be unique within a domain.
The version of this activity.
Note
The combination of activity type name and version must be unique with in a domain.
The activityId
of the activity task.
The specified string must not start or end with whitespace. It must not contain a :
(colon), /
(slash), |
(vertical bar), or any control characters ( \u0000-\u001f
| \u007f-\u009f
). Also, it must not contain the literal string arn
.
Data attached to the event that can be used by the decider in subsequent workflow tasks. This data isn't sent to the activity.
The input provided to the activity task.
The maximum duration for this activity task.
The duration is specified in seconds, an integer greater than or equal to 0
. You can use NONE
to specify unlimited duration.
Note
A schedule-to-close timeout for this activity task must be specified either as a default for the activity type or through this field. If neither this field is set nor a default schedule-to-close timeout was specified at registration time then a fault is returned.
If set, specifies the name of the task list in which to schedule the activity task. If not specified, the defaultTaskList
registered with the activity type is used.
Note
A task list for this activity task must be specified either as a default for the activity type or through this field. If neither this field is set nor a default task list was specified at registration time then a fault is returned.
The specified string must not start or end with whitespace. It must not contain a :
(colon), /
(slash), |
(vertical bar), or any control characters ( \u0000-\u001f
| \u007f-\u009f
). Also, it must not contain the literal string arn
.
The name of the task list.
If set, specifies the priority with which the activity task is to be assigned to a worker. This overrides the defaultTaskPriority specified when registering the activity type using RegisterActivityType. Valid values are integers that range from Java's Integer.MIN_VALUE
(-2147483648) to Integer.MAX_VALUE
(2147483647). Higher numbers indicate higher priority.
For more information about setting task priority, see Setting Task Priority in the Amazon SWF Developer Guide .
If set, specifies the maximum duration the activity task can wait to be assigned to a worker. This overrides the default schedule-to-start timeout specified when registering the activity type using RegisterActivityType.
The duration is specified in seconds, an integer greater than or equal to 0
. You can use NONE
to specify unlimited duration.
Note
A schedule-to-start timeout for this activity task must be specified either as a default for the activity type or through this field. If neither this field is set nor a default schedule-to-start timeout was specified at registration time then a fault is returned.
If set, specifies the maximum duration a worker may take to process this activity task. This overrides the default start-to-close timeout specified when registering the activity type using RegisterActivityType.
The duration is specified in seconds, an integer greater than or equal to 0
. You can use NONE
to specify unlimited duration.
Note
A start-to-close timeout for this activity task must be specified either as a default for the activity type or through this field. If neither this field is set nor a default start-to-close timeout was specified at registration time then a fault is returned.
If set, specifies the maximum time before which a worker processing a task of this type must report progress by calling RecordActivityTaskHeartbeat. If the timeout is exceeded, the activity task is automatically timed out. If the worker subsequently attempts to record a heartbeat or returns a result, it is ignored. This overrides the default heartbeat timeout specified when registering the activity type using RegisterActivityType.
The duration is specified in seconds, an integer greater than or equal to 0
. You can use NONE
to specify unlimited duration.
Provides the details of the RequestCancelActivityTask
decision. It isn't set for other decision types.
The activityId
of the activity task to be canceled.
Provides the details of the CompleteWorkflowExecution
decision. It isn't set for other decision types.
The result of the workflow execution. The form of the result is implementation defined.
Provides the details of the FailWorkflowExecution
decision. It isn't set for other decision types.
A descriptive reason for the failure that may help in diagnostics.
Details of the failure.
Provides the details of the CancelWorkflowExecution
decision. It isn't set for other decision types.
Details of the cancellation.
Provides the details of the ContinueAsNewWorkflowExecution
decision. It isn't set for other decision types.
The input provided to the new workflow execution.
If set, specifies the total duration for this workflow execution. This overrides the defaultExecutionStartToCloseTimeout
specified when registering the workflow type.
The duration is specified in seconds, an integer greater than or equal to 0
. You can use NONE
to specify unlimited duration.
Note
An execution start-to-close timeout for this workflow execution must be specified either as a default for the workflow type or through this field. If neither this field is set nor a default execution start-to-close timeout was specified at registration time then a fault is returned.
The task list to use for the decisions of the new (continued) workflow execution.
The name of the task list.
The task priority that, if set, specifies the priority for the decision tasks for this workflow execution. This overrides the defaultTaskPriority specified when registering the workflow type. Valid values are integers that range from Java's Integer.MIN_VALUE
(-2147483648) to Integer.MAX_VALUE
(2147483647). Higher numbers indicate higher priority.
For more information about setting task priority, see Setting Task Priority in the Amazon SWF Developer Guide .
Specifies the maximum duration of decision tasks for the new workflow execution. This parameter overrides the defaultTaskStartToCloseTimout
specified when registering the workflow type using RegisterWorkflowType.
The duration is specified in seconds, an integer greater than or equal to 0
. You can use NONE
to specify unlimited duration.
Note
A task start-to-close timeout for the new workflow execution must be specified either as a default for the workflow type or through this parameter. If neither this parameter is set nor a default task start-to-close timeout was specified at registration time then a fault is returned.
If set, specifies the policy to use for the child workflow executions of the new execution if it is terminated by calling the TerminateWorkflowExecution action explicitly or due to an expired timeout. This policy overrides the default child policy specified when registering the workflow type using RegisterWorkflowType.
The supported child policies are:
TERMINATE
– The child executions are terminated.REQUEST_CANCEL
– A request to cancel is attempted for each child execution by recording a WorkflowExecutionCancelRequested
event in its history. It is up to the decider to take appropriate actions when it receives an execution history with this event.ABANDON
– No action is taken. The child executions continue to run.Note
A child policy for this workflow execution must be specified either as a default for the workflow type or through this parameter. If neither this parameter is set nor a default child policy was specified at registration time then a fault is returned.
The list of tags to associate with the new workflow execution. A maximum of 5 tags can be specified. You can list workflow executions with a specific tag by calling ListOpenWorkflowExecutions or ListClosedWorkflowExecutions and specifying a TagFilter.
The version of the workflow to start.
The IAM role to attach to the new (continued) execution.
Provides the details of the RecordMarker
decision. It isn't set for other decision types.
The name of the marker.
The details of the marker.
Provides the details of the StartTimer
decision. It isn't set for other decision types.
The unique ID of the timer.
The specified string must not start or end with whitespace. It must not contain a :
(colon), /
(slash), |
(vertical bar), or any control characters ( \u0000-\u001f
| \u007f-\u009f
). Also, it must not contain the literal string arn
.
The data attached to the event that can be used by the decider in subsequent workflow tasks.
The duration to wait before firing the timer.
The duration is specified in seconds, an integer greater than or equal to 0
.
Provides the details of the CancelTimer
decision. It isn't set for other decision types.
The unique ID of the timer to cancel.
Provides the details of the SignalExternalWorkflowExecution
decision. It isn't set for other decision types.
The workflowId
of the workflow execution to be signaled.
The runId
of the workflow execution to be signaled.
The name of the signal.The target workflow execution uses the signal name and input to process the signal.
The input data to be provided with the signal. The target workflow execution uses the signal name and input data to process the signal.
The data attached to the event that can be used by the decider in subsequent decision tasks.
Provides the details of the RequestCancelExternalWorkflowExecution
decision. It isn't set for other decision types.
The workflowId
of the external workflow execution to cancel.
The runId
of the external workflow execution to cancel.
The data attached to the event that can be used by the decider in subsequent workflow tasks.
Provides the details of the StartChildWorkflowExecution
decision. It isn't set for other decision types.
The type of the workflow execution to be started.
The name of the workflow type.
Note
The combination of workflow type name and version must be unique with in a domain.
The version of the workflow type.
Note
The combination of workflow type name and version must be unique with in a domain.
The workflowId
of the workflow execution.
The specified string must not start or end with whitespace. It must not contain a :
(colon), /
(slash), |
(vertical bar), or any control characters ( \u0000-\u001f
| \u007f-\u009f
). Also, it must not contain the literal string arn
.
The data attached to the event that can be used by the decider in subsequent workflow tasks. This data isn't sent to the child workflow execution.
The input to be provided to the workflow execution.
The total duration for this workflow execution. This overrides the defaultExecutionStartToCloseTimeout specified when registering the workflow type.
The duration is specified in seconds, an integer greater than or equal to 0
. You can use NONE
to specify unlimited duration.
Note
An execution start-to-close timeout for this workflow execution must be specified either as a default for the workflow type or through this parameter. If neither this parameter is set nor a default execution start-to-close timeout was specified at registration time then a fault is returned.
The name of the task list to be used for decision tasks of the child workflow execution.
Note
A task list for this workflow execution must be specified either as a default for the workflow type or through this parameter. If neither this parameter is set nor a default task list was specified at registration time then a fault is returned.
The specified string must not start or end with whitespace. It must not contain a :
(colon), /
(slash), |
(vertical bar), or any control characters ( \u0000-\u001f
| \u007f-\u009f
). Also, it must not contain the literal string arn
.
The name of the task list.
A task priority that, if set, specifies the priority for a decision task of this workflow execution. This overrides the defaultTaskPriority specified when registering the workflow type. Valid values are integers that range from Java's Integer.MIN_VALUE
(-2147483648) to Integer.MAX_VALUE
(2147483647). Higher numbers indicate higher priority.
For more information about setting task priority, see Setting Task Priority in the Amazon SWF Developer Guide .
Specifies the maximum duration of decision tasks for this workflow execution. This parameter overrides the defaultTaskStartToCloseTimout
specified when registering the workflow type using RegisterWorkflowType.
The duration is specified in seconds, an integer greater than or equal to 0
. You can use NONE
to specify unlimited duration.
Note
A task start-to-close timeout for this workflow execution must be specified either as a default for the workflow type or through this parameter. If neither this parameter is set nor a default task start-to-close timeout was specified at registration time then a fault is returned.
If set, specifies the policy to use for the child workflow executions if the workflow execution being started is terminated by calling the TerminateWorkflowExecution action explicitly or due to an expired timeout. This policy overrides the default child policy specified when registering the workflow type using RegisterWorkflowType.
The supported child policies are:
TERMINATE
– The child executions are terminated.REQUEST_CANCEL
– A request to cancel is attempted for each child execution by recording a WorkflowExecutionCancelRequested
event in its history. It is up to the decider to take appropriate actions when it receives an execution history with this event.ABANDON
– No action is taken. The child executions continue to run.Note
A child policy for this workflow execution must be specified either as a default for the workflow type or through this parameter. If neither this parameter is set nor a default child policy was specified at registration time then a fault is returned.
The list of tags to associate with the child workflow execution. A maximum of 5 tags can be specified. You can list workflow executions with a specific tag by calling ListOpenWorkflowExecutions or ListClosedWorkflowExecutions and specifying a TagFilter.
The IAM role attached to the child workflow execution.
Provides the details of the ScheduleLambdaFunction
decision. It isn't set for other decision types.
A string that identifies the Lambda function execution in the event history.
The name, or ARN, of the Lambda function to schedule.
The data attached to the event that the decider can use in subsequent workflow tasks. This data isn't sent to the Lambda task.
The optional input data to be supplied to the Lambda function.
The timeout value, in seconds, after which the Lambda function is considered to be failed once it has started. This can be any integer from 1-300 (1s-5m). If no value is supplied, than a default value of 300s is assumed.
None
Exceptions
SWF.Client.exceptions.UnknownResourceFault
SWF.Client.exceptions.OperationNotPermittedFault