Kafka (Open-Source) Trigger
This section describes how to create an open-source 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 differences between DMS for Kafka and open-source Kafka, see Comparing DMS for Kafka and Open-Source Kafka.
Notes and Constraints
- Currently, open-source Kafka triggers are available only in the following regions: CN North-Beijing4, CN East-Shanghai1, CN-Hong Kong, AP-Bangkok, AP-Singapore, and LA-Santiago 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
- You have created a function.
- You have enabled the VPC access for the function and configured the subnet permissions for the Kafka security group. For details, see Configuring Networks. The network configuration must be the same as that of the ECS where Kafka is deployed, including the VPC and subnet.
Creating an Open-Source 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 an open-source Kafka trigger Parameter
Description
Example Value
Trigger Type
Mandatory.
Select Kafka (Open-Source).
Kafka (Open-Source)
Connection Address
Mandatory.
Addresses of brokers running Kafka. Separate the addresses with commas (,).
100.85.125.151:9094,100.95.145.47:9094
Topic
Mandatory.
Enter the created topic.
topic-1
Batch Size
Mandatory.
Enter the maximum number of data records that can be processed by a function at a time. The value ranges from 1 to 10000.
100
- Click OK.
Enabling a Kafka Trigger
By default, open-source Kafka triggers are disabled. To use such a trigger, click Enable on the Trigger page.
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
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 Templates
Select Kafka (Open-Source) 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.
- Click Test. The function test result is displayed.
Helpful Links
Manage function triggers through APIs. For details, see Function Trigger APIs.
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