Queries asynchronous tasks that meet specific conditions.

StatefulAsyncInvocation represents asynchronous tasks. Asynchronous tasks (StatefulAsyncInvocation) allow you to manage the states of asynchronous invocations. The asynchronous task feature is more suitable for task scenarios.

Request headers

This operation uses only common request headers. For more information, see Common parameters.

Request syntax

GET /services/{serviceName[.qualifier]}/functions/{functionName}/stateful-async-invocations HTTP/1.1

Request parameters

ParameterTypePositionRequiredExampleDescription
serviceNameStringPathYesservice_name

The name of the service to which the asynchronous task belongs.

functionNameStringPathYesfunction_name

The name of the function whose asynchronous tasks you want to query.

qualifierStringPathNoalias

The version or alias of the service to which the asynchronous task belongs.

invocationIdPrefixStringPathNojob-***

The name prefix of the asynchronous tasks. This parameter is used to limit the names of the returned asynchronous tasks. For example, if you set the invocationidPrefix parameter to job, the names of the returned invocations must start with job.

nextTokenStringQueryYese026ae92-61e5-472f-b32d-1c9e3c4e****

The token that is used to specify the start position when you query the asynchronous tasks. You do not need to specify this parameter in the first query. If the number of invocations exceeds the limit, the nextToken parameter is returned, the value of which can be used in subsequent calls to obtain more results.

limitIntegerQueryNo50

The maximum number of asynchronous tasks to return. Valid values: [1,100]. Default value: 50.

startedTimeBeginLongQueryNo161941846****

The beginning of the time range in which the asynchronous tasks are started. Unit: milliseconds.

startedTimeEndLongQueryNo161941846****

The end of the time range in which the asynchronous tasks are started. Unit: milliseconds.

sortOrderByTimeStringQueryNoasc

The method that you want to use to sort the returned asynchronous tasks. Valid values:

  • asc: the ascending order
  • desc: the descending order
includePayloadBooleanQueryNotrue
  • Specifies whether to return the invocationPayload parameter in the response. true: returns the invocationPayload parameter in the response.
  • false: does not return the invocationPayload parameter in the response.
Note The invocationPayload parameter indicates the input parameters of an asynchronous task.

Response parameters

ParameterTypeExampleDescription
invocationsArray

The list of asynchronous tasks.

startedTimeLong2020-08-20T02:28:21Z

The start time of the asynchronous task.

endTimeLong2020-08-20T02:38:21Z

The end time of the asynchronous task.

functionNameStringfunction_name

The name of the function whose asynchronous tasks you want to query.

qualifierStringalias

The version or alias of the service to which the asynchronous task belongs.

serviceNameStringservice_name

The name of the service to which the asynchronous task belongs.

invocationIdStringe026ae92-61e5-472f-b32d-1c9e3c4e****

The asynchronous task ID.

requestIdString403fcbd6-ec41-401f-9fa7-386f3d3d****

The request ID of the asynchronous task.

statusStringSucceeded

The state of the asynchronous task.

  • Enqueued: The asynchronous invocation is enqueued and is waiting to be executed.
  • Dequeued: The asynchronous invocation is dequeued and is waiting to be triggered.
  • Running: The invocation is being executed.
  • Succeeded: The invocation is successful.
  • Failed: The invocation fails.
  • Stopped: The invocation is terminated.
  • Stopping: The invocation is being terminated.
  • Expired: You have configured a validity period for the asynchronous invocation. The invocation was expired and discarded.
  • Invalid: The task is invalid and not triggered due to a specific reason. For example, the function was deleted.
  • Retrying: The asynchronous invocation is being retried due to an execution error.
destinationStatusStringSucceeded

The destination status of the asynchronous task.

invocationErrorMessageStringUnhandledInvocationError

The error message returned for the asynchronous task.

InvocationPayloadStringhello world

The event triggered by the asynchronous task.

alreadyRetriedTimesLong3

The maximum number of retries that are allowed after the asynchronous task fails. Default value: 3. Valid values: [0,8].

nextTokenStringcaeba0be03****f84eb48b699f0a4883

The token used to obtain more results. If the number of asynchronous tasks exceeds the limit, the nextToken parameter is returned. You must include this parameter in subsequent calls to obtain more results. You do not need to specify this parameter in the first call.

Examples

Sample requests

GET /services/{serviceName[.qualifier]}/functions/function_name/stateful-async-invocations?nextToken=e026ae92-61e5-472f-b32d-1c9e3c4e****&limit=50&sortOrderByTime=asc&includePayload=true HTTP/1.1
Host:fc-ram.aliyuncs.com
Content-Type:application/json
Common request header

Sample success responses

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "invocations" : [ {
    "functionName" : "function_name",
    "qualifier" : "alias",
    "serviceName" : "service_name",
    "invocationId" : "e026ae92-61e5-472f-b32d-1c9e3c4e****",
    "requestId" : "403fcbd6-ec41-401f-9fa7-386f3d3d****",
    "status" : "Succeeded",
    "destinationStatus" : "Succeeded",
    "invocationErrorMessage" : "UnhandledInvocationError",
    "InvocationPayload" : "hello world",
    "alreadyRetriedTimes" : 3
  } ],
  "nextToken" : "caeba0be03****f84eb48b699f0a4883"
}