SWF / Client / respond_decision_task_completed
respond_decision_task_completed#
- SWF.Client.respond_decision_task_completed(**kwargs)#
Used by deciders to tell the service that the DecisionTask identified by the
taskToken
has successfully completed. Thedecisions
argument specifies the list of decisions made while processing the task.A
DecisionTaskCompleted
event is added to the workflow history. TheexecutionContext
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 thedecisions
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' )
- Parameters:
taskToken (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, itstaskToken
must also be passed. This enables it to provide its progress and respond with results.decisions (list) –
The list of decisions (possibly empty) made by the decider while processing this decision task. See the docs for the Decision structure for details.
(dict) –
Specifies a decision made by the decider. A decision can be one of these types:
CancelTimer
– Cancels a previously started timer and records aTimerCanceled
event in the history.CancelWorkflowExecution
– Closes the workflow execution and records aWorkflowExecutionCanceled
event in the history.CompleteWorkflowExecution
– Closes the workflow execution and records aWorkflowExecutionCompleted
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. AWorkflowExecutionContinuedAsNew
event is recorded in the history.FailWorkflowExecution
– Closes the workflow execution and records aWorkflowExecutionFailed
event in the history.RecordMarker
– Records aMarkerRecorded
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 aRequestCancelExternalWorkflowExecutionInitiated
event in the history.ScheduleActivityTask
– Schedules an activity task.SignalExternalWorkflowExecution
– Requests a signal to be delivered to the specified external workflow execution and records aSignalExternalWorkflowExecutionInitiated
event in the history.StartChildWorkflowExecution
– Requests that a child workflow execution be started and records aStartChildWorkflowExecutionInitiated
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 aTimerStarted
event in the history. This timer fires after the specified delay and record aTimerFired
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
The ordering of decisions should follow a logical flow. Some decisions might not make sense in the current context of the workflow execution and therefore fails.
A limit on your account was reached.
The decision lacks sufficient permissions.
One of the following events might be added to the history to indicate an error. The event attribute’s
cause
parameter indicates the cause. Ifcause
is set toOPERATION_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
– AScheduleActivityTask
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
– ARequestCancelActivityTask
decision failed. This could happen if there is no open activity task with the specified activityId.StartTimerFailed
– AStartTimer
decision failed. This could happen if there is another open timer with the same timerId.CancelTimerFailed
– ACancelTimer
decision failed. This could happen if there is no open timer with the specified timerId.StartChildWorkflowExecutionFailed
– AStartChildWorkflowExecution
decision failed. This could happen if the workflow type specified isn’t registered, is deprecated, or the decision isn’t properly configured.SignalExternalWorkflowExecutionFailed
– ASignalExternalWorkflowExecution
decision failed. This could happen if theworkflowID
specified in the decision was incorrect.RequestCancelExternalWorkflowExecutionFailed
– ARequestCancelExternalWorkflowExecution
decision failed. This could happen if theworkflowID
specified in the decision was incorrect.CancelWorkflowExecutionFailed
– ACancelWorkflowExecution
decision failed. This could happen if there is an unhandled decision task pending in the workflow execution.CompleteWorkflowExecutionFailed
– ACompleteWorkflowExecution
decision failed. This could happen if there is an unhandled decision task pending in the workflow execution.ContinueAsNewWorkflowExecutionFailed
– AContinueAsNewWorkflowExecution
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
– AFailWorkflowExecution
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
decisionType (string) – [REQUIRED]
Specifies the type of the decision.
scheduleActivityTaskDecisionAttributes (dict) –
Provides the details of the
ScheduleActivityTask
decision. It isn’t set for other decision types.activityType (dict) – [REQUIRED]
The type of the activity task to schedule.
name (string) – [REQUIRED]
The name of this activity.
Note
The combination of activity type name and version must be unique within a domain.
version (string) – [REQUIRED]
The version of this activity.
Note
The combination of activity type name and version must be unique with in a domain.
activityId (string) – [REQUIRED]
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 stringarn
.control (string) –
Data attached to the event that can be used by the decider in subsequent workflow tasks. This data isn’t sent to the activity.
input (string) –
The input provided to the activity task.
scheduleToCloseTimeout (string) –
The maximum duration for this activity task.
The duration is specified in seconds, an integer greater than or equal to
0
. You can useNONE
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.
taskList (dict) –
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 stringarn
.name (string) – [REQUIRED]
The name of the task list.
taskPriority (string) –
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) toInteger.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.
scheduleToStartTimeout (string) –
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 useNONE
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.
startToCloseTimeout (string) –
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 useNONE
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.
heartbeatTimeout (string) –
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 useNONE
to specify unlimited duration.
requestCancelActivityTaskDecisionAttributes (dict) –
Provides the details of the
RequestCancelActivityTask
decision. It isn’t set for other decision types.activityId (string) – [REQUIRED]
The
activityId
of the activity task to be canceled.
completeWorkflowExecutionDecisionAttributes (dict) –
Provides the details of the
CompleteWorkflowExecution
decision. It isn’t set for other decision types.result (string) –
The result of the workflow execution. The form of the result is implementation defined.
failWorkflowExecutionDecisionAttributes (dict) –
Provides the details of the
FailWorkflowExecution
decision. It isn’t set for other decision types.reason (string) –
A descriptive reason for the failure that may help in diagnostics.
details (string) –
Details of the failure.
cancelWorkflowExecutionDecisionAttributes (dict) –
Provides the details of the
CancelWorkflowExecution
decision. It isn’t set for other decision types.details (string) –
Details of the cancellation.
continueAsNewWorkflowExecutionDecisionAttributes (dict) –
Provides the details of the
ContinueAsNewWorkflowExecution
decision. It isn’t set for other decision types.input (string) –
The input provided to the new workflow execution.
executionStartToCloseTimeout (string) –
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 useNONE
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.
taskList (dict) –
The task list to use for the decisions of the new (continued) workflow execution.
name (string) – [REQUIRED]
The name of the task list.
taskPriority (string) –
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) toInteger.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.
taskStartToCloseTimeout (string) –
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 useNONE
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.
childPolicy (string) –
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 aWorkflowExecutionCancelRequested
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.
tagList (list) –
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.
(string) –
workflowTypeVersion (string) –
The version of the workflow to start.
lambdaRole (string) –
The IAM role to attach to the new (continued) execution.
recordMarkerDecisionAttributes (dict) –
Provides the details of the
RecordMarker
decision. It isn’t set for other decision types.markerName (string) – [REQUIRED]
The name of the marker.
details (string) –
The details of the marker.
startTimerDecisionAttributes (dict) –
Provides the details of the
StartTimer
decision. It isn’t set for other decision types.timerId (string) – [REQUIRED]
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 stringarn
.control (string) –
The data attached to the event that can be used by the decider in subsequent workflow tasks.
startToFireTimeout (string) – [REQUIRED]
The duration to wait before firing the timer.
The duration is specified in seconds, an integer greater than or equal to
0
.
cancelTimerDecisionAttributes (dict) –
Provides the details of the
CancelTimer
decision. It isn’t set for other decision types.timerId (string) – [REQUIRED]
The unique ID of the timer to cancel.
signalExternalWorkflowExecutionDecisionAttributes (dict) –
Provides the details of the
SignalExternalWorkflowExecution
decision. It isn’t set for other decision types.workflowId (string) – [REQUIRED]
The
workflowId
of the workflow execution to be signaled.runId (string) –
The
runId
of the workflow execution to be signaled.signalName (string) – [REQUIRED]
The name of the signal.The target workflow execution uses the signal name and input to process the signal.
input (string) –
The input data to be provided with the signal. The target workflow execution uses the signal name and input data to process the signal.
control (string) –
The data attached to the event that can be used by the decider in subsequent decision tasks.
requestCancelExternalWorkflowExecutionDecisionAttributes (dict) –
Provides the details of the
RequestCancelExternalWorkflowExecution
decision. It isn’t set for other decision types.workflowId (string) – [REQUIRED]
The
workflowId
of the external workflow execution to cancel.runId (string) –
The
runId
of the external workflow execution to cancel.control (string) –
The data attached to the event that can be used by the decider in subsequent workflow tasks.
startChildWorkflowExecutionDecisionAttributes (dict) –
Provides the details of the
StartChildWorkflowExecution
decision. It isn’t set for other decision types.workflowType (dict) – [REQUIRED]
The type of the workflow execution to be started.
name (string) – [REQUIRED]
The name of the workflow type.
Note
The combination of workflow type name and version must be unique with in a domain.
version (string) – [REQUIRED]
The version of the workflow type.
Note
The combination of workflow type name and version must be unique with in a domain.
workflowId (string) – [REQUIRED]
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 stringarn
.control (string) –
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.
input (string) –
The input to be provided to the workflow execution.
executionStartToCloseTimeout (string) –
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 useNONE
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.
taskList (dict) –
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 stringarn
.name (string) – [REQUIRED]
The name of the task list.
taskPriority (string) –
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) toInteger.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.
taskStartToCloseTimeout (string) –
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 useNONE
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.
childPolicy (string) –
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 aWorkflowExecutionCancelRequested
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.
tagList (list) –
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.
(string) –
lambdaRole (string) –
The IAM role attached to the child workflow execution.
scheduleLambdaFunctionDecisionAttributes (dict) –
Provides the details of the
ScheduleLambdaFunction
decision. It isn’t set for other decision types.id (string) – [REQUIRED]
A string that identifies the Lambda function execution in the event history.
name (string) – [REQUIRED]
The name, or ARN, of the Lambda function to schedule.
control (string) –
The data attached to the event that the decider can use in subsequent workflow tasks. This data isn’t sent to the Lambda task.
input (string) –
The optional input data to be supplied to the Lambda function.
startToCloseTimeout (string) –
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.
executionContext (string) – User defined context to add to workflow execution.
- Returns:
None
Exceptions
SWF.Client.exceptions.UnknownResourceFault
SWF.Client.exceptions.OperationNotPermittedFault