mqttClient
mqttClient
component: mqtt client. Publish the current message data to the specified topic of the mqtt broker.
# Configuration
This component allows the reuse of shared connection clients through the server
field. See Component Connection Reuse for reference.
Field | Type | Description | Default value |
---|---|---|---|
topic | string | Publish topic, can using Component Configuration Variables. | None |
server | string | mqtt broker address | None |
username | string | Username | None |
password | string | Password | None |
maxReconnectInterval | time.Duration | Reconnect interval, supports configuration in the form of 10s, 1m, etc. | None |
qos | int | qos | None |
cleanSession | bool | Whether to clean session | false |
clientID | string | Client Id | Random ID |
CAFile | string | Configure to use ssl connection to mqtt broker | None |
CertFile | string | Configure to use ssl connection to mqtt broker | None |
CertKeyFile | string | Configure to use ssl connection to mqtt broker | None |
# Relation Type
- Success: Execution successful, send the message to the
Success
chain - Failure: Execution failed, send the message to the
Failure
chain
# Execution result
This component will not change the content of msg
, metadata
and msgType
.
# Configuration example
{
"id": "s2",
"type": "mqttClient",
"name": "Push data to mqtt Broker",
"configuration": {
"server": "127.0.0.1:1883",
"topic": "/device/msg/${deviceId}"
}
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# Application example
Application example reference: mqttClient (opens new window)
{
"ruleChain": {
"id":"rule01",
"name": "Test rule chain",
"root": true
},
"metadata": {
"nodes": [
{
"id": "s1",
"type": "jsTransform",
"name": "Transform",
"configuration": {
"jsScript": "metadata['name']='test02';\n metadata['deviceId']='id01';\n msg['addField']='addValue2'; return {'msg':msg,'metadata':metadata,'msgType':msgType};"
}
},
{
"id": "s2",
"type": "mqttClient",
"name": "Push data to mqtt Broker",
"configuration": {
"server": "127.0.0.1:1883",
"topic": "/device/msg/${deviceId}"
}
}
],
"connections": [
{
"fromId": "s1",
"toId": "s2",
"type": "Success"
}
]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Edit this page on GitHub (opens new window)
Last Updated: 2024/10/23, 10:13:01