Redis Stream Endpoint
Redis Endpoint v0.23.0+ is used to create and start a Redis stream service. It can subscribe to data on different stream names, and then route it to different rule chains for processing.
TIP
1.This component is an extension component, and you need to import an additional extension library: rulego-components (opens new window) 2.It requires support from Redis version 5.0 or above.
# Type
endpoint/redis/stream
# Startup Configuration
This component allows the reuse of shared connection clients through the server
field. See Component Connection Reuse for reference.
Field | Type | Required | Description | Default Value |
---|---|---|---|---|
server | string | Yes | redis server address | None |
password | string | No | Password | None |
db | int | No | db index | 0 |
groupId | string | No | Consumer Group ID | rulego |
# Response
Before responding with exchange.Out.SetBody
, you need to specify the responseTopic
parameter through exchange.Out.Headers()
or exchange.Out.Msg.Metadata
. The component will then respond with data to the specified topic:
exchange.Out.GetMsg().Metadata.PutValue("responseTopic", "device.msg.response")
// or
exchange.Out.Headers().Add("responseTopic", "device.msg.response")
exchange.Out.SetBody([]byte("ok"))
2
3
4
Response parameter configuration:
Field | Type | Required | Description | Default Value |
---|---|---|---|---|
responseTopic | string | Yes | Response Topic | - |
# Example
Below is an example code using the endpoint: