Redis Sub Endpoint
Redis Endpoint v0.22.0+ is used to create and start a Redis subscription service. It can subscribe to data on different topics 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/redis
# 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 | string | No | db index | 0 |
# 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: