All Products
Search
Document Center

:Destinations for asynchronous invocations

Last Updated:Apr 01, 2026

When you invoke a function asynchronously, Function Compute queues the request and returns a response immediately — without waiting for execution to complete. Configure a destination to route invocation results to a downstream service automatically. Function Compute sends the result context to the destination after each invocation succeeds or exhausts all retry attempts.

How it works

image

Use cases

  • Retain discarded events for further processing: If an asynchronous invocation fails after all retry attempts, Function Compute discards the event. Configure a failure destination to forward the invocation context to a message service — such as ApsaraMQ for RocketMQ — for analysis or reprocessing. Alternatively, set another function as the destination to run custom error-handling logic.

  • Notify downstream services of invocation results: After a successful invocation, Function Compute sends the request context to the configured success destination. For example, if you use Function Compute to decompress ZIP files uploaded to OSS, configure a success destination to trigger a notification when the job completes.

Supported destinations

Function Compute supports the following services as destinations for asynchronous invocations. You can configure destinations per function, per version, and per alias.

Note

Only event functions can be configured as destinations. HTTP functions are not supported. For more information, see Select a function type.

Destination serviceRequired permissionPayload limit
Simple Message Queue (formerly MNS)mns:SendMessage or mns:PublishMessage64 KB
Function Computefc:InvokeFunction128 KB
EventBridgeeventbridge:PutEvents64 KB
ApsaraMQ for RocketMQmq:PUB4 MB
Important

Simple Message Queue (formerly MNS) and EventBridge have a 64 KB payload limit. If the invocation payload approaches this limit, delivery may fail. For large payloads, use ApsaraMQ for RocketMQ (4 MB limit) instead.

Event payload sent to the destination

Simple Message Queue (formerly MNS), Function Compute, and ApsaraMQ for RocketMQ

Function Compute passes the following JSON as the message body or function payload:

{
  "timestamp": 1660120276975,
  "requestContext": {
    "requestId": "xxx",
    "functionArn": "acs:fc:::services/{serviceName}/functions/{functionName}",
    "condition": "FunctionResourceExhausted",
    "approximateInvokeCount": 3
  },
  "requestPayload": "",
  "responseContext": {
    "statusCode": 200,
    "functionError": ""
  },
  "responsePayload": ""
}
ParameterDescription
timestampThe timestamp of the invocation.
requestContextThe context of the request.
requestContext.requestIdThe request ID of the asynchronous invocation.
requestContext.functionArnThe ARN of the asynchronously invoked function.
requestContext.conditionThe invocation error code.
requestContext.approximateInvokeCountThe number of times the invocation was attempted. A value greater than 1 means Function Compute retried the function.
requestPayloadThe original payload of the function request.
responseContextThe response context.
responseContext.statusCodeThe system-level return code of the function invocation. A non-200 value indicates a system error.
responseContext.functionErrorThe invocation error message.
responsePayloadThe raw payload returned by the function execution.

EventBridge

Function Compute passes the invocation record as the data field in the event. For more information about the event format, see Event overview.

{
    "datacontenttype": "application/json",
    "aliyunaccountid": "143xxxx",
    "data": {
        "requestContext": {
            "condition": "",
            "approximateInvokeCount": 1,
            "requestId": "0fcb7f0c-xxxx",
            "functionArn": "acs:fc:::services/xxxx.LATEST/functions/xxxx"
        },
        "requestPayload": "",
        "responsePayload": "",
        "responseContext": {
            "functionError": "",
            "statusCode": 200
        },
        "timestamp": 1660120276975
    },
    "subject": "acs:fc:::services/xxxx.LATEST/functions/xxxx",
    "source": "acs:fc",
    "type": "fc:AsyncInvoke:succeeded",
    "aliyunpublishtime": "2021-01-03T09:44:31.233Asia/Shanghai",
    "specversion": "1.0",
    "aliyuneventbusname": "xxxxxxx",
    "id": "ecc4865xxxxxx",
    "time": "2021-01-03T01:44:31Z",
    "aliyunregionid": "cn-shanghai-vpc",
    "aliyunpublishaddr": "199.99.xxx.xxx"
}

The type field is set to fc:AsyncInvoke:succeeded for successful invocations.

Configure a destination

Prerequisites

Before you begin, ensure that you have:

Configure a success or failure destination

  1. Log on to the Function Compute console. In the left-side navigation pane, click Services & Functions.

  2. In the top navigation bar, select a region. On the Services page, click the desired service.

  3. On the Functions page, click the name of the target function. On the function details page, click the Asynchronous Configurations tab.

  4. Configure the destination:

    • For successful invocations: In the Destination for Successful Invocation section, click Modify. In the panel, set Invoke Other Services upon Success to Enable, then configure the destination service.

    • For failed invocations: In the Destination for Failed Invocation section, click Modify. In the panel, set Invoke Other Services upon Failure to Enable, then configure the destination service.

  5. Configure the parameters for the selected destination service:

    Destination serviceParameters
    Function ComputeService Name, Version or Alias, Function Name. Only event functions are supported.
    Simple Message Queue (formerly MNS)Destination Type (Queue or Topic), then Queue name or Topic name. Queue delivers to one consumer; Topic uses publish-subscribe for multiple consumers.
    ApsaraMQ for RocketMQInstances (select the instance), Topic (select the topic).
    EventBridgeCustom Event Bus (specify the event bus name).
  6. Click OK.

Important

Avoid circular invocations. For example, if Function B is the success destination for Function A, and Function A is the success destination for Function B, a successful invocation of either function triggers an infinite loop.

Handle callback failures

A destination callback may fail if the service role lacks permissions or the destination service is unavailable. Function Compute retries or records an error depending on the HTTP status code:

Error codeCauseSystem behavior
5xxThrottling, content errors, or other transient issuesRetries with exponential backoff. Initial retry interval: 500 ms. Maximum retry duration: 30 minutes.
4xxInsufficient permissions, incorrect parameters, deleted resource, or payload exceeds the destination limitReturns an error and records the error message.

Monitor destination invocations

If a callback fails, Function Compute records the failure in monitoring metrics. To view them:

  1. Log on to the Function Compute console.

  2. In the left-side navigation pane, choose Advanced Features > Monitoring.

  3. In the Service Name list, click the name of the destination service.

The following metrics are available for destinations:

MetricMetric IDDescription
Destination invocation errorsFunctionDestinationErrorsNumber of failed destination callback requests. Aggregated at 1-minute or 1-hour granularity.
Destination invocation successesFunctionDestinationSucceedNumber of successful destination callback requests. Aggregated at 1-minute or 1-hour granularity.

For a full list of monitoring metrics, see Monitoring metrics.

What's next