Using a DMS Trigger
For details about the DMS event source, see Supported Event Sources.
Prerequisites
Before creating a DMS trigger, make sure you have prepared the following:
- You have created a message queue and consumer group, for example, the queue-test queue and the group-dms consumer group. For details, see Creating a Queue and Creating a Consumer Group.
- You have created a function on FunctionGraph. For details, see Creating and Initializing a Function.
Setting an Agency
Before creating a DMS trigger, set an agency to delegate FunctionGraph to access DMS. If no agency is set, FunctionGraph will not be able to load the created message queue or the message queue will be unavailable. For details on how to create an agency, see Creating an Agency.
Since you did not specify an agency while creating the HelloWorld function, specify one first.
- Log in to the FunctionGraph console, and choose Functions > Function List in the navigation pane.
- Click the HelloWorld function.
- On the displayed function details page, click the Configuration tab.
- Set the agency to serverless-trust created in Creating an Agency. Click Save.
Creating a DMS Trigger
- Log in to the FunctionGraph console, and choose Functions > Function List in the navigation pane.
- Click the HelloWorld function.
- On the displayed function details page, click the Triggers tab.
- Click Create Trigger.
- Set the following parameters:
- Trigger Type: Select Distributed Message Service (DMS).
- Queue Name: Select a queue, for example, queue-test.
- Consumer Group: Select a consumer group, for example, group-dms.
- Pull Period (s): Set an interval at which the DMS trigger will poll for messages.
- Click OK.
Creating a Message to Trigger the Function
- Log in to the DMS console, and choose Queue Manager in the navigation pane.
- On the Queue Manager page, click queue-test.
- On the queue details page, click Create Message.
- In the Create Message dialog box, configure the message information according to Table 1.
- Click OK.
- On the Consumer Groups tab page, check the value of Messages Available in the same row as group-dms.
The DMS trigger polls for messages based on the pull period set in Creating a DMS Trigger. When messages are detected, they are retrieved to trigger the function. For details about example events, see Supported Event Sources.
Viewing the Execution Result
- Log in to the FunctionGraph console, and choose Functions > Function List in the navigation pane.
- Click the HelloWorld function.
- On the displayed function details page, click the Logs tab to query the function running logs.
- Click View Context in the same row as a log to view log details.
Last Article: Using an SMN Trigger
Next Article: Using an APIG Trigger
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.