Using an SMN Trigger
This section describes how to create an SMN trigger and publish a message to trigger a function.
For details about the SMN event source, see Supported Event Sources.
Prerequisites
- You have created an SMN topic, for example, smn-test. For details, see Creating a Topic.
- You have created a function. For details, see Creating a Function from Scratch.
Creating an SMN Trigger
- Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
- Click the function to be configured to go to the function details page.
- Choose Configuration > Triggers and click Create Trigger.
Figure 1 Creating a trigger
- Set the following parameters:
- Trigger Type: Select Simple Message Notification (SMN).
- Topic Name: Select a topic, for example, smn-test.
- Click OK.
After the SMN trigger is created, a subscription is generated for the corresponding topic on the SMN console.
Publishing a Message to Trigger the Function
On the SMN console, publish a message to the smn-test topic. For details, see Publishing a Text Message.
Table 1 describes the parameters required for publishing a message.
Parameter |
Description |
---|---|
Subject |
Enter SMN-Test. |
Message Format |
Select Text. |
Message |
Enter {"message":"hello"}. |
After a message is published, the function is triggered automatically. For details about example events, see Supported Event Sources.
Viewing the Execution Result
- Return to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
- Click a function to go to the function details page.
- Choose Monitoring > Logs to query function running logs.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.