Help Center/ FunctionGraph/ User Guide/ Creating Triggers/ Using an Open-Source Kafka Trigger
Updated on 2023-11-30 GMT+08:00

Using an Open-Source Kafka Trigger

This section describes how to create an open-source Kafka trigger and configure an event to trigger a function.

If you use an open-source Kafka trigger for a function, FunctionGraph periodically polls messages from a specific topic in Kafka and passes the messages as an input parameter to invoke the function.

For details about the differences between DMS for Kafka and open-source Kafka, see Comparing DMS for Kafka and Open-Source Kafka.

Prerequisites

Before creating a trigger, ensure that you have prepared the following:

  • You have created a function.
  • You have enabled VPC access for the function. For details, see Configuring the Network.

Creating an Open-Source Kafka 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

  4. Set the following parameters:

    • Trigger Type: Select Kafka (OPENSOURCEKAFKA).
    • Connection Address: Addresses of brokers running Kafka. Separate the addresses with commas (,).
    • Topic: Enter one or more topics.
    • Batch Size: Maximum number of data records that can be processed by the function at a time.

  5. Click OK.

    The network configuration must be the same as that of the ECS where Kafka is deployed, including the VPC and subnet.

Enabling a Kafka Trigger

By default, open-source Kafka triggers are disabled. To use such a trigger, click Enable on the Trigger page.

If a trigger cannot be disabled, contact technical support.

Configuring a Kafka 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 Kafka (OPENSOURCEKAFKA) to use the built-in Kafka 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 Kafka event template, which is used in this example without modifications.

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