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.
Prerequisites
Before creating a trigger, make sure you have prepared the following:
- You have created a function on FunctionGraph. For details, see Creating and Initializing a Function.
- You have enabled VPC access for the function. For details, see Configuring VPC Access.
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.
- 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.
- Click OK.
The network configuration must be the same as that of the ECS where Kafka is deployed, including the VPC and subnet.
Enabling an Open-Source 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 an Open-Source Kafka Event to Trigger the Function
- On the Code tab page, click Configure Test Event.
- Set the parameters described in Table 1 and click Create.
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 open-source 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.
Test event
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.
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