PollForActivityTask
Used by workers to get an ActivityTask from the specified activity
taskList
. This initiates a long poll, where the service holds the HTTP
connection open and responds as soon as a task becomes available. The maximum time the service
holds on to the request before responding is 60 seconds. If no task is available within 60
seconds, the poll returns an empty result. An empty result, in this context, means that an
ActivityTask is returned, but that the value of taskToken is an empty string. If a task is
returned, the worker should use its type to identify and process it correctly.
Important
Workers should set their client side socket timeout to at least 70 seconds (10 seconds higher than the maximum time service may hold the poll request).
Access Control
You can use IAM policies to control this action's access to Amazon SWF resources as follows:
-
Use a
Resource
element with the domain name to limit the action to only specified domains. -
Use an
Action
element to allow or deny permission to call this action. -
Constrain the
taskList.name
parameter by using aCondition
element with theswf:taskList.name
key to allow the action to access only certain task lists.
If the caller doesn't have sufficient permissions to invoke the action, or the
parameter values fall outside the specified constraints, the action fails. The associated
event attribute's cause
parameter is set to OPERATION_NOT_PERMITTED
.
For details and example IAM policies, see Using IAM to Manage Access to Amazon SWF
Workflows in the Amazon SWF Developer Guide.
Request Syntax
{
"domain": "string
",
"identity": "string
",
"taskList": {
"name": "string
"
}
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
- domain
-
The name of the domain that contains the task lists being polled.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 256.
Required: Yes
- identity
-
Identity of the worker making the request, recorded in the
ActivityTaskStarted
event in the workflow history. This enables diagnostic tracing when problems arise. The form of this identity is user defined.Type: String
Length Constraints: Maximum length of 256.
Required: No
- taskList
-
Specifies the task list to poll for activity tasks.
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 be the literal stringarn
.Type: TaskList object
Required: Yes
Response Syntax
{
"activityId": "string",
"activityType": {
"name": "string",
"version": "string"
},
"input": "string",
"startedEventId": number,
"taskToken": "string",
"workflowExecution": {
"runId": "string",
"workflowId": "string"
}
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- activityId
-
The unique ID of the task.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 256.
- activityType
-
The type of this activity task.
Type: ActivityType object
- input
-
The inputs provided when the activity task was scheduled. The form of the input is user defined and should be meaningful to the activity implementation.
Type: String
Length Constraints: Maximum length of 32768.
- startedEventId
-
The ID of the
ActivityTaskStarted
event recorded in the history.Type: Long
- taskToken
-
The opaque string used as a handle on the task. This token is used by workers to communicate progress and response information back to the system about the task.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 1024.
- workflowExecution
-
The workflow execution that started this activity task.
Type: WorkflowExecution object
Errors
For information about the errors that are common to all actions, see Common Errors.
- LimitExceededFault
-
Returned by any operation if a system imposed limitation has been reached. To address this fault you should either clean up unused resources or increase the limit by contacting AWS.
HTTP Status Code: 400
- OperationNotPermittedFault
-
Returned when the caller doesn't have sufficient permissions to invoke the action.
HTTP Status Code: 400
- UnknownResourceFault
-
Returned when the named resource cannot be found with in the scope of this operation (region or domain). This could happen if the named resource was never created or is no longer available for this operation.
HTTP Status Code: 400
Examples
PollForActivityTask Example
This example illustrates one usage of PollForActivityTask.
Sample Request
POST / HTTP/1.1
Host: swf.us-east-1.amazonaws.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.25) Gecko/20111212 Firefox/3.6.25 ( .NET CLR 3.5.30729; .NET4.0E)
Accept: application/json, text/javascript, */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: application/x-amz-json-1.0
X-Requested-With: XMLHttpRequest
X-Amz-Date: Mon, 16 Jan 2012 03:53:52 GMT
X-Amz-Target: SimpleWorkflowService.PollForActivityTask
Content-Encoding: amz-1.0
X-Amzn-Authorization: AWS3 AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE,Algorithm=HmacSHA256,SignedHeaders=Host;X-Amz-Date;X-Amz-Target;Content-Encoding,Signature=dv0H1RPYucoIcRckspWO0f8xG120MWZRKmj3O5/A4rY=
Referer: http://swf.us-east-1.amazonaws.com/explorer/index.html
Content-Length: 108
Pragma: no-cache
Cache-Control: no-cache
{"domain": "867530901",
"taskList":
{"name": "mainTaskList"},
"identity": "VerifyCreditCardWorker01"}
Sample Response
HTTP/1.1 200 OK
Content-Length: 837
Content-Type: application/json
x-amzn-RequestId: b48fb6b5-3ff5-11e1-a23a-99d60383ae71
{"activityId": "verification-27",
"activityType":
{"name": "activityVerify",
"version": "1.0"},
"input": "5634-0056-4367-0923,12/12,437",
"startedEventId": 11,
"taskToken": "AAAAKgAAAAEAAAAAAAAAAX9p3pcp3857oLXFUuwdxRU5/zmn9f40XaMF7VohAH4jOtjXpZu7GdOzEi0b3cWYHbG5b5dpdcTXHUDPVMHXiUxCgr+Nc/wUW9016W4YxJGs/jmxzPln8qLftU+SW135Q0UuKp5XRGoRTJp3tbHn2pY1vC8gDB/K69J6q668U1pd4Cd9o43//lGgOIjN0/Ihg+DO+83HNcOuVEQMM28kNMXf7yePh31M4dMKJwQaQZG13huJXDwzJOoZQz+XFuqFly+lPnCE4XvsnhfAvTsh50EtNDEtQzPCFJoUeld9g64V/FS/39PHL3M93PBUuroPyHuCwHsNC6fZ7gM/XOKmW4kKnXPoQweEUkFV/J6E6+M1reBO7nJADTrLSnajg6MY/viWsEYmMw/DS5FlquFaDIhFkLhWUWN+V2KqiKS23GYwpzgZ7fgcWHQF2NLEY3zrjam4LW/UW5VLCyM3FpVD3erCTi9IvUgslPzyVGuWNAoTmgJEWvimgwiHxJMxxc9JBDR390iMmImxVl3eeSDUWx8reQltiviadPDjyRmVhYP8",
"workflowExecution":
{"runId": "cfa2bd33-31b0-4b75-b131-255bb0d97b3f",
"workflowId": "20110927-T-1"}
}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: