Nacos Config Set
x/nacosConfigSet: writes (publishes) config to nacos — creates if absent, overwrites if present. Routes to Success on success, Failure on error.
Requires extension library: rulego-components-discovery (opens new window)
# Configuration
Inherits Common Connection Config. Extra fields:
| Field | Type | Description | Default |
|---|---|---|---|
| dataId | string | Config Data ID | none (required) |
| group | string | Config group | DEFAULT_GROUP |
| content | string | Config content, supports ${msg.xx} | empty |
| format | string | Config format: json/yaml/properties/text | json |
# Behavior
- Full overwrite: nacos stores config as text; writing replaces the whole content (nacos is not structure-aware; no field-level API).
- Template:
contentsupports${msg.xx}dynamic rendering. - Patch one field: use a read-modify-write chain, see below.
# Output
On success the msg flows to Success unchanged (the node does not read back).
# Examples
Write a fixed config:
{
"id": "set_cfg",
"type": "x/nacosConfigSet",
"configuration": {
"server": "127.0.0.1:8848",
"dataId": "app.json",
"group": "DEFAULT_GROUP",
"content": "{\"featureX\":true}",
"format": "json"
}
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# Read-modify-write (patch one field)
x/nacosConfigGet reads → jsTransform parses & patches → x/nacosConfigSet writes back:
{
"ruleChain": {"name": "config-patch", "root": true},
"metadata": {
"nodes": [
{"id": "g", "type": "x/nacosConfigGet", "configuration": {
"server": "127.0.0.1:8848", "dataId": "app.json"}},
{"id": "p", "type": "jsTransform", "configuration": {
"jsScript": "var c=JSON.parse(msg); c.featureX=true; return {msg:JSON.stringify(c),metadata:metadata,msgType:msgType};"}},
{"id": "s", "type": "x/nacosConfigSet", "configuration": {
"server": "ref://g", "dataId": "app.json", "format": "json", "content": "${msg}"}}
],
"connections": [
{"fromId": "g", "toId": "p", "type": "Success"},
{"fromId": "p", "toId": "s", "type": "Success"}
]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Read-modify-write is not atomic; concurrent writes to the same dataId may suffer last-write-wins. Config changes are usually low-frequency, so the risk is small.
# Related
- Service call: x/nacosServiceCall
- Config read: x/nacosConfigGet
- Config listen: endpoint/nacos
Edit this page on GitHub (opens new window)
Last Updated: 2026/08/01, 05:05:14