Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Setting Task Priority - Amazon Simple Workflow Service

Setting Task Priority

By default, tasks on a task list are delivered based upon their arrival time: tasks that are scheduled first are generally run first, as far as possible. By setting an optional task priority, you can give priority to certain tasks: Amazon SWF will attempt to deliver higher-priority tasks on a task list before those with lower priority.

Note

Tasks that are scheduled first generally run first, but this is not guaranteed.

You can set task priorities for both workflows and activities. A workflow's task priority doesn't affect the priority of any activity tasks it schedules, nor does it affect any child workflows it starts. The default priority for an activity or workflow is set (either by you or by Amazon SWF) during registration, and the registered task priority is always used unless it is overridden while scheduling the activity or starting a workflow execution.

Task priority values can range from "-2147483648" to "2147483647", with higher numbers indicating higher priority. If you don't set the task priority for an activity or workflow, it will be assigned a priority of zero ("0").

Setting Task Priority for Workflows

You can set the task priority for a workflow when you register it or start it. The task priority that is set when the workflow type is registered is used as the default for any workflow executions of that type, unless it is overridden when starting the workflow execution.

To register a workflow type with a default task priority, set the defaultTaskPriority option when using the RegisterWorkflowType action:

{ "domain": "867530901", "name": "expeditedOrderWorkflow", "version": "1.0", "description": "Expedited customer orders workflow", "defaultTaskStartToCloseTimeout": "600", "defaultExecutionStartToCloseTimeout": "3600", "defaultTaskList": {"name": "mainTaskList"}, "defaultTaskPriority": "10", "defaultChildPolicy": "TERMINATE" }

You can override a workflow type's registered task priority when you start a workflow execution with StartWorkflowExecution:

{ "childPolicy": "TERMINATE", "domain": "867530901", "executionStartToCloseTimeout": "1800", "input": "arbitrary-string-that-is-meaningful-to-the-workflow", "tagList": ["music purchase", "digital", "ricoh-the-dog"], "taskList": {"name": "specialTaskList"}, "taskPriority": "-20", "taskStartToCloseTimeout": "600", "workflowId": "20110927-T-1", "workflowType": {"name": "customerOrderWorkflow", "version": "1.0"}, }

You can also override the registered task priority when starting a child workflow or when continuing a workflow as new, such as when responding to a decision with RespondDecisionTaskCompleted.

To set a child workflow's task priority, provide the value in startChildWorkflowExecutionDecisionAttributes:

{ "taskToken": "AAAAKgAAAAEAAAAAAAAAA...", "decisions": [ { "decisionType": "StartChildWorkflowExecution", "startChildWorkflowExecutionDecisionAttributes": { "childPolicy": "TERMINATE", "control": "digital music", "executionStartToCloseTimeout": "900", "input": "201412-Smith-011x", "taskList": {"name": "specialTaskList"}, "taskPriority": "5", "taskStartToCloseTimeout": "600", "workflowId": "verification-workflow", "workflowType": { "name": "MyChildWorkflow", "version": "1.0" } } } ] }

When continuing a workflow as new, set the task priority in continueAsNewWorkflowExecutionDecisionAttributes:

{ "taskToken": "AAAAKgAAAAEAAAAAAAAAA...", "decisions": [ { "decisionType": "ContinueAsNewWorkflowExecution", "continueAsNewWorkflowExecutionDecisionAttributes": { "childPolicy": "TERMINATE", "executionStartToCloseTimeout": "1800", "input": "5634-0056-4367-0923,12/12,437", "taskList": {"name": "specialTaskList"}, "taskStartToCloseTimeout": "600", "taskPriority": "100", "workflowTypeVersion": "1.0" } } ] }

Setting Task Priority for Activities

You can set the task priority for an activity either when registering it or when scheduling it. The task priority that is set when registering an activity type is used as the default priority when the activity is run, unless it is overridden when scheduling the activity.

To set task priority when registering an activity type, set the defaultTaskPriority option when using the RegisterActivityType action:

{ "defaultTaskHeartbeatTimeout": "120", "defaultTaskList": {"name": "mainTaskList"}, "defaultTaskPriority": "10", "defaultTaskScheduleToCloseTimeout": "900", "defaultTaskScheduleToStartTimeout": "300", "defaultTaskStartToCloseTimeout": "600", "description": "Verify the customer credit card", "domain": "867530901", "name": "activityVerify", "version": "1.0" }

To schedule a task with a task priority, use the taskPriority option when scheduling the activity with the RespondDecisionTaskCompleted action:

{ "taskToken": "AAAAKgAAAAEAAAAAAAAAA...", "decisions": [ { "decisionType": "ScheduleActivityTask", "scheduleActivityTaskDecisionAttributes": { "activityId": "verify-account", "activityType": { "name": "activityVerify", "version": "1.0" }, "control": "digital music", "input": "abab-101", "taskList": {"name": "mainTaskList"}, "taskPriority": "15" } } ] }

Actions that Return Task Priority Information

You can get information about the set task priority (or set default task priority) from the following Amazon SWF actions:

  • DescribeActivityType returns the defaultTaskPriority of the activity type in the configuration section of the response.

  • DescribeWorkflowExecution returns the taskPriority of the workflow execution in the executionConfiguration section of the response.

  • DescribeWorkflowType returns the defaultTaskPriority of the workflow type in the configuration section of the response.

  • GetWorkflowExecutionHistory and PollForDecisionTask provide task priority information in the activityTaskScheduledEventAttributes, decisionTaskScheduledEventAttributes, workflowExecutionContinuedAsNewEventAttributes, and workflowExecutionStartedEventAttributes sections of the response.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.