Asynchronous Notification Policy
In asynchronous mode, FunctionGraph queues requests, does not wait for the execution result, and directly returns a response to the client. To set the asynchronous request retry upon failure or obtain the asynchronous request result, you can configure the asynchronous notification policy.
- Retry: By default, FunctionGraph does not retry if a function fails due to a code error. If your function needs retry, for example, if third-party services often fail to be invoked, configure retry to improve the success rate.
- Result notification: FunctionGraph automatically sends the asynchronous execution result of a function to downstream services for further processing. For example, storing execution failure information in OBS for cause analysis, or pushing execution success information to DIS or triggering the function again.
Notes and Constraints
Restricted Scenario |
Description |
---|---|
Using functions that are invoked asynchronously |
The return value of a function in asynchronous mode cannot exceed 256 KB; otherwise, an empty value will be returned. |
Configuring async notification to notify the target service |
To avoid cyclic invocation, do not set two functions as asynchronous execution targets of each other. |
Prerequisites
- You have configured an agency with operation permissions on the target service for the function to notify the target service in asynchronous mode. For details about how to configure an agency, see Configuring Agency Permissions.
Configuring an Asynchronous Notification Policy
- Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
- Click the name of a function.
- Choose Configuration > Async Notification.
- On the displayed page, click Edit.
Figure 1 Setting parameters
Table 2 Asynchronous notification parameters Parameter
Description
Asynchronous Execution Notification Policy
- Max. Retries: maximum number of retries when asynchronous invocation fails. Value range: 0–3. Default value: 3.
- Max. Validity Period (s): maximum lifetime of a message in seconds. Value range: 1–86,400.
- Asynchronous Invocation Status Persistence: This parameter is displayed after you enable LTS. For details, see Enabling Asynchronous Invocation Status Persistence.
Success Notification
Target Service: to which a notification will be sent if a function is executed successfully.
- FunctionGraph
- Function Name: name of the function that will receive the notification.
- Version/Alias: Select the version or alias of the function.
- OBS
- Target Bucket Directory: Select the OBS bucket directory for storing notification messages.
- Object Prefix Directory: Enter an object prefix directory to filter the object files for storing notification messages.
- Object Validity Period (Days): Configure the time duration after which an object will expire. The OBS server automatically clears expired objects. The value ranges from 0 to 365. The value 0 indicates that the object does not expire.
- DIS
Target Stream: Select the stream that receives notification messages.
- SMN
Topic Name: Select the topic that receives notification messages.
Failure Notification
Target Service: to which a notification will be sent if a function fails to be executed.
- FunctionGraph
- Function Name: name of the function that will receive the notification.
- Version/Alias: Select the version or alias of the function.
- OBS
- Target Bucket Directory: Select the OBS bucket directory for storing notification messages.
- Object Prefix Directory: Enter an object prefix directory to filter the object files for storing notification messages.
- Object Validity Period (Days): Configure the time duration after which an object will expire. The OBS server automatically clears expired objects. The value ranges from 0 to 365. The value 0 indicates that the object does not expire.
- DIS
Target Stream: Select the stream that receives notification messages.
- SMN
Topic Name: Select the topic that receives notification messages.
- Click OK.
Notification Message Structure
The following is an example of an asynchronous invocation notification sent by FunctionGraph to the target.
{ "timestamp": "2020-08-20T12:00:00.000Z+08:00", "request_context": { "request_id": "1167bf8c-87b0-43ab-8f5f-26b16c64f252", "function_urn": "urn:fss:xx-xxxx-x:xxxxxxx:function:xxxx:xxxx:latest", "condition": "", "approximate_invoke_count": 0 }, "request_payload": "", "response_context": { "status_code": 200, "function_error": "" }, "response_payload": "hello world!" }
Parameter |
Description |
---|---|
timestamp |
Execution start time |
request_context |
Request context. |
request_context.request_id |
ID of an asynchronous invocation request. |
request_context. function_urn |
URN of the function that is to be executed asynchronously. |
request_context.condition |
Invocation error type. |
request_context. approximate_invoke_count |
Number of asynchronous invocation times. If the value is greater than 1, function execution has been retried. |
request_payload |
Original request payload. |
response_context |
Response context. |
response_context.statusCode |
System return code of the invoked function. If the code is not 200, a system error occurred. |
response_context.function_error |
Invocation error information. |
response_payload |
Payload returned after function execution. |
Enabling Asynchronous Invocation Status Persistence
With asynchronous invocation status persistence enabled, you can query the execution status of each asynchronous invocation in logs reported to LTS.

By default, you do not have the permission to enable Asynchronous Invocation Status Persistence. You need to submit a service ticket to add a whitelist.
- Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
- Click the name of a function to go to the function details page. Choose Configuration > Async Notification.
- On the displayed page, click Enable LTS in the upper part of the page to enable LTS. (Skip this step if LTS has been enabled.)
During this process, the system automatically calls the LTS API to create a log group (named starting with function-async-log-group) and a log stream (named starting with function-async-log-stream) on the LTS console.
- After the LTS is enabled, click Edit. The Asynchronous Invocation Status Persistence parameter is displayed.
- Enable Asynchronous Invocation Status Persistence and select the log group and log stream automatically created in 3.
Figure 2 Enabling Asynchronous Invocation Status Persistence
- Configure log structuring on the LTS console.
- Log in to the LTS console. In the navigation pane, choose Log Management. You can view the automatically created log group and log stream in the log group list.
Figure 3 Log group list
- In the displayed log stream list, click the name of the log stream you want to view.
- On the log stream details page, click Log Settings in the upper right corner, as shown in Figure 4.
- In the displayed dialog box, click the Cloud Structuring Parsing tab and configure log structuring, as shown in Figure 5.
- Select Delimiter method.
- Enter x|x|0|0|0|x in the sample log event area.
The placeholder indicates that the first two fields are of the string type, the middle three fields are of the long type, and the last field is of the string type.
- Select the vertical bar (|) as the delimiter.
- Click Intelligent Extraction in step 3 to generate fields, and click
to change the field names by referring to Table 4. Figure 6 shows the modified fields.
- Click Save.
- Log in to the LTS console. In the navigation pane, choose Log Management. You can view the automatically created log group and log stream in the log group list.
Helpful Links
- Manage asynchronous notification for functions using APIs. For details, see Asynchronous Execution Notification APIs.
- If the message indicating insufficient permissions is displayed when you modify the asynchronous notification, add the FunctionGraph Administrator permission. For details, see Creating a User and Granting Permissions.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot