MQTT Endpoint
Mqtt Endpoint is used to create and start MQTT receiving service, it can subscribe to different topic data, and then route it to different rule chains for processing.
# Type
mqtt
# Startup configuration
Field | Type | Required | Description | Default |
---|---|---|---|---|
Server | string | Yes | mqtt broker address | - |
Username | string | No | username | 0 |
Password | string | No | password | - |
QOS | int | No | QOS | 0 |
CleanSession | bool | No | CleanSession | false |
ClientID | string | No | client ID | default random number |
CAFile | string | No | CA file path | - |
CertFile | string | No | Cert file path | - |
CertKeyFile | string | No | CertKey file path | - |
# Response
Before exchange.Out.SetBody
response, you need to specify the topic
parameter through exchange.Out.Headers()
, and the component will respond to the specified topic data:
exchange.Out.Headers().Add("topic", "device.msg.response")
exchange.Out.SetBody([]byte("ok"))
1
2
2
Response parameter configuration:
Field | Type | Required | Description | Default |
---|---|---|---|---|
topic | string | Yes | topic | - |
qos | int | No | QOS | 0 |
# Examples
The following are example codes using endpoint:
Edit this page on GitHub (opens new window)
Last Updated: 2024/06/16, 16:49:02