Nats Endpoint
Nats Endpoint v0.21.0+ is used to create and start a Nats 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 requires the inclusion of an additional extension library: rulego-components (opens new window)
# Type
nats
# Startup Configuration
Field | Type | Required | Description | Default Value |
---|---|---|---|---|
server | string | Yes | nats server address | None |
username | string | No | Username | None |
password | string | No | Password | None |
# Response
Before responding with exchange.Out.SetBody
, you need to specify the topic
parameter through exchange.Out.Headers()
. The component will then respond with data to the specified topic:
exchange.Out.Headers().Add("topic", "device.msg.response")
exchange.Out.SetBody([]byte("ok"))
1
2
2
Response parameter configuration:
Field | Type | Required | Description | Default Value |
---|---|---|---|---|
topic | string | Yes | Topic | - |
# Example
Below is an example code using the endpoint:
Edit this page on GitHub (opens new window)
Last Updated: 2024/06/16, 16:49:02