DMS (for Kafka) Trigger
This section describes how to create a Kafka trigger to enable FunctionGraph to periodically poll new messages in a specified topic of a Kafka instance and pass the messages as input parameters to invoke functions.
For details about the Kafka event source, see Supported Event Sources.

For details about the differences between DMS for Kafka and open-source Kafka, see Comparing DMS for Kafka and Open-Source Kafka.
Notes and Constraints
- Kafka triggers are supported in all regions except LA-Sao Paulo1. You can check whether the trigger type is supported on the console.
- The valid payload size of a request body is 6 MB when a Kafka trigger is used.
- In cases of Kafka data processing failure, the Kafka trigger will discard records that are larger than 6 MB.
Prerequisites
- Function and configuration:
- You have created a function.
- You have configured DMS agency permissions for the function. For details about how to create an agency, see Configuring Agency Permissions.
- You have enabled VPC access for the function. For details, see Configuring Networks.
- DMS for Kafka:
- You have created a Kafka instance. For details, see Buying an Instance.
- You have created a topic under a Kafka instance. For details, see Creating a Topic.
- You have configured the subnet permissions for the Kafka security group. For details, see .
Creating a Kafka 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
- Configure the following parameters.
Table 1 Parameters of a Kafka trigger Parameter
Description
Example Value
Trigger Type
Mandatory.
Select DMS (for Kafka).
DMS (for Kafka)
Instance
Mandatory.
Select a created Kafka instance. If no instance is available, click Create Instance.
kafka-fg
Topic
Mandatory.
Select a topic of the Kafka premium instance. You can create a Kafka trigger with multiple topics. You do not need to create one such trigger for each topic in the same instance. If no topic is available, click Create Topic.
topic-fg
Batch Size
Mandatory.
Enter the number of messages consumed from the topic each time. The value ranges from 1 to 1000.
100
- Click OK.
Configuring a Kafka Event to Trigger the Function
- Return 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.
- On the function details page, select a version.
- On the Code tab page, click Test. The Configure Test Event dialog box is displayed.
- Set the parameters described in Table 2 and click Save.
Table 2 Test event information Parameter
Description
Example Value
Configure Test Event
You can choose to create a test event or edit an existing one.
Use the default option Create new test event.
Create new test event
Event Templates
Select DMS (for Kafka) to use the built-in Kafka event template.
DMS (for Kafka)
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.
kafka-123test
Event data
The system automatically loads the built-in Kafka event template, which is used in this example without modifications.
-
- Click Test. The function test result is displayed.
Helpful Links
- Manage function triggers through APIs. For details, see Function Trigger APIs.
- FAQ about Kafka triggers: Can I Configure a Kafka Trigger in a Different Subnet from My Function?
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