This section describes how to create a Kafka trigger and configure a Kafka event to trigger a function.
After a Kafka trigger is used, FunctionGraph periodically polls for new messages in a specific topic in a Kafka instance and passes the messages as input parameters to invoke functions. For details about the DMS for Kafka event source, see Supported Event Sources.
Before creating a Kafka trigger, make sure you have prepared the following:
After VPC access is enabled, you need to configure corresponding subnet permissions for the Kafka security group. For details about how to enable VPC access, see Configuring VPC Access. Figure 1 Configuring a subnet
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 DMS (for Kafka) 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. |
The event template is as follows:
{"event_version": "v1.0","event_time": 1576737962,"trigger_type": "KAFKA","region": "xx-xxxx-1","records": [{"messages": ["kafka message1","kafka message2","kafka message3","kafka message4","kafka message5"],"instance_id": "81335d56-b9fe-4679-ba95-7030949cc76b","topic_id": "topic-test"}]}