Help Center/ FunctionGraph/ User Guide/ Creating Triggers/ Using a DMS (for RabbitMQ) Trigger
Updated on 2024-08-15 GMT+08:00

Using a DMS (for RabbitMQ) Trigger

This section describes how to create a DMS (for RabbitMQ) trigger for a function. Currently, only the fan-out exchange mode is supported. After a DMS (for RabbitMQ) trigger is used, FunctionGraph periodically polls for new messages in a specific topic bound to the exchange of a RabbitMQ instance and passes the messages as input parameters to invoke functions. For details about the DMS (for RabbitMQ) event source, see Supported Event Sources.

Prerequisites

  • You have created a function. For details, see Creating a Function from Scratch.
  • You have enabled VPC access. For details, see Configuring the Network.
  • A RabbitMQ instance has been created. For details, see Buying an Instance.
  • The rules of the security group of the instance have been correctly configured.
    1. In the Network section on the Basic Information tab page, click the name of the security group.
    2. Click the Inbound Rules tab to view the inbound rules of the security group.
      1. SSL disabled

        For intra-VPC access, inbound access through port 5672 must be allowed.

        For public access, inbound access through port 15672 must be allowed.

      2. SSL enabled

        For intra-VPC access, inbound access through port 5671 must be allowed.

        For public access, inbound access through port 15671 must be allowed.

Creating a RabbitMQ Trigger

  1. Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
  2. Click the function to be configured to go to the function details page.
  3. Choose Configuration > Triggers and click Create Trigger.

    Figure 1 Creating a trigger

  1. Set the following parameters:

    • Trigger Type: Select DMS (for RabbitMQ).
    • *Instance: Select a RabbitMQ instance.
    • *Password: Enter the password of the RabbitMQ instance.
    • *Exchange: Enter the name of the exchange to be used.
    • Virtual Host: Enter a custom virtual host name.
    • *Batch Size: Set the number of messages to be retrieved from a topic each time.

  2. Click OK.

After VPC access is enabled, you need to configure corresponding subnet permissions for the RabbitMQ security group. For details about how to configure VPC access, see Configuring the Network.

Configuring a DMS (for RabbitMQ) Event to Trigger the Function

  1. Return to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
  2. Click the function to be configured to go to the function details page.
  3. On the function details page, select a version.
  4. On the Code tab page, click Test. The Configure Test Event dialog box is displayed.
  5. Set the parameters described in Table 1 and click Save.

    Table 1 Test event information

    Parameter

    Description

    Configure Test Event

    You can choose to create a test event or edit an existing one.

    Use the default option Create new test event.

    Event Template

    Select rabbitmq-event-template.

    Event Name

    The event name can contain 1 to 25 characters and must start with a letter and end with a letter or digit. Only letters, digits, underscores (_), and hyphens (-) are allowed. For example, kafka-123test.

    Event data

    The system automatically loads the built-in RabbitMQ event template, which is used in this example without modifications.

  1. Click Test. The function test result is displayed.