Kafka Endpoint
Kafka Endpoint is used to create and start Kafka subscription service, which can subscribe to different topic data, and then route it to different rule chains for processing.
TIP
This component is an extension component, and you need to import an additional extension library: rulego-components (opens new window)
# Type
endpoint/kafka
# Startup configuration
Field | Type | Required | Description | Default |
---|---|---|---|---|
Brokers | []string | Yes | Kafka server address list | - |
groupId v0.23.0+ | string | No | Consumer Group ID | rulego |
# Response
Before exchange.Out.SetBody
responds, you need to specify the responseTopic
parameter through exchange.Out.Headers()
or exchange.Out.Msg.Metadata
, and the component will respond to the specified topic data:
exchange.Out.GetMsg().Metadata.PutValue("responseTopic", "device.msg.response")
// or
exchange.Out.Headers().Add("responseTopic", "device.msg.response")
exchange.Out.SetBody([]byte("ok"))
1
2
3
4
2
3
4
Response parameter configuration:
Field | Type | Required | Description | Default |
---|---|---|---|---|
responseTopic | string | Yes | response Topic | - |
partition | int | No | Partition | 0 |
key | string | No | Partition Key | - |
# Examples
The following are example codes using endpoint:
Edit this page on GitHub (opens new window)
Last Updated: 2024/10/23, 10:13:01