All Products
Search
Document Center

Function Compute:PutFunctionAsyncInvokeConfig

Last Updated:Jun 11, 2024

Creates or updates the asynchronous invocation configurations of a function.

The system creates or updates configurations for the function based on whether asynchronous invocation configurations exist when you call the PutFunctionAsyncInvokeConfig operation.

  • If the function is not configured with asynchronous invocation configurations, asynchronous invocation configurations are created when you can call the PutFunctionAsyncInvokeConfig operation.

  • If the function is already configured with asynchronous invocation configurations, the asynchronous invocation configurations are updated based on the passed configurations when you can call the PutFunctionAsyncInvokeConfig operation. Items that are not specified remain unchanged.

StatefulAsyncInvocation indicates whether the asynchronous task feature is enabled. The asynchronous task feature allows you to manage states of asynchronous invocations and is suitable for task scenarios.

Request headers

This operation does not have operation-specific request headers and uses only common request headers. For more information, see Common parameters.

Request syntax

PUT /services/{serviceName[.qualifier]}/functions/{functionName}/async-invoke-config HTTP/1.1

Request parameters

Parameter

Type

Position

Required

Example

Description

serviceName

String

Path

Yes

service_name

The name of the service that contains the function for which the asynchronous invocation configurations are configured.

functionName

String

Path

Yes

testHelloWorld

The name of the function for which the asynchronous invocation configurations are configured.

qualifier

String

Path

No

alias

The alias or version of the service that contains the function for which the asynchronous invocation configurations are configured.

Object

Body

No

The asynchronous invocation configurations.

destinationConfig

DestinationConfig

Body

No

The configuration struct of the destination for asynchronous invocations.

maxAsyncEventAgeInSeconds

Long

Body

No

300

The maximum validity period of a message. Valid values: [1,604800]. Default value: 86400. Unit: seconds.

maxAsyncRetryAttempts

Long

Body

No

3

The maximum number of retries that are allowed after an asynchronous invocation fails. Default value: 3. Valid values: 0 to 8.

statefulInvocation

Boolean

Body

No

true

Specifies whether to enable the asynchronous task feature. Valid values:

  • true

  • false

Response parameters

Parameter

Type

Example

Description

createdTime

String

2020-08-20T02:28:21Z

The time when the service was created.

destinationConfig

DestinationConfig

The configuration struct of the destination for asynchronous invocations.

functionName

String

testHelloWorld

The name of the function for which the asynchronous invocation configurations are configured.

lastModifiedTime

String

2020-09-10T02:45:02Z

The time when the asynchronous invocation configurations were last modified.

maxAsyncEventAgeInSeconds

Long

1

The maximum validity period of messages. Valid values: [1, 2592000]. Unit: seconds.

maxAsyncRetryAttempts

Long

1

The maximum number of retries that are allowed after an asynchronous invocation fails. Default value: 3. Valid values: 0 to 8.

qualifier

String

alias

The alias or version of the service that contains the function for which the asynchronous invocation configurations are configured.

serviceName

String

service_name

The name of the service that contains the function for which the asynchronous invocation configurations are configured.

statefulInvocation

Boolean

true

Indicates whether the asynchronous task feature is enabled. Valid values:

  • true

  • false

Examples

Sample requests

PUT /2016-08-15/services/service_name.alias/functions/testHelloWorld/async-invoke-config HTTP/1.1
Common request headers

{
  "destinationConfig" : {
    "onFailure" : {
      "destination" : "acs:mns:cn-shanghai:1986***743:/queues/failure/messages"
    },
    "onSuccess" : {
      "destination" : "acs:mns:cn-shanghai:1986***743:/queues/success/messages"
    }
  },
  "maxAsyncEventAgeInSeconds" : 300,
  "maxAsyncRetryAttempts" : 3,
  "statefulInvocation" : true
}

Sample success responses

JSON format

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

{
  "createdTime" : "2020-08-20T02:28:21Z",
  "destinationConfig" : {
    "onFailure" : {
      "destination" : "acs:mns:cn-shanghai:1986***743:/queues/failure/messages"
    },
    "onSuccess" : {
      "destination" : "acs:mns:cn-shanghai:1986***743:/queues/success/messages"
    }
  },
  "functionName" : "testHelloWorld",
  "lastModifiedTime" : "2020-09-10T02:45:02Z",
  "maxAsyncEventAgeInSeconds" : 1,
  "maxAsyncRetryAttempts" : 1,
  "qualifier" : "alias",
  "serviceName" : "service_name",
  "statefulInvocation" : true
}