Nacos 配置监听端点
endpoint/nacos 端点:订阅 nacos 配置,配置变更自动触发规则链。路由 from.path 填 nacos Data ID(逗号分隔可监听多个)。
# 配置
继承 公共连接配置,额外字段:
| 字段 | 类型 | 说明 | 默认值 |
|---|---|---|---|
| group | string | 配置分组(endpoint 级,所有路由共用) | DEFAULT_GROUP |
路由:
| 字段 | 说明 |
|---|---|
| from.path | 监听的 Data ID,逗号分隔可监听多个 |
| to.path | 配置变更后触发的规则链 ID(一般为当前链) |
nacos 配置监听按
(dataId, group)订阅,不支持通配符或「监听全部」。需监听多个 Data ID 时在from.path逗号分隔列举。
# 触发消息
配置变更时注入规则链:
msg.Data= 新配置内容metadata.dataId= 触发变更的 Data ID
# 示例
监听 app.json,变更触发当前链(jsTransform 处理):
{
"ruleChain": {"id": "cfg-listen", "root": true},
"metadata": {
"firstNodeIndex": 0,
"endpoints": [
{
"id": "ep_cfg",
"type": "endpoint/nacos",
"configuration": {
"server": "127.0.0.1:8848",
"group": "DEFAULT_GROUP"
},
"routers": [
{"from": {"path": "app.json"}, "to": {"path": "cfg-listen"}}
]
}
],
"nodes": [
{"id": "n1", "type": "jsTransform", "configuration": {
"jsScript": "return {msg:'配置['+metadata.dataId+']='+msg,metadata:metadata,msgType:msgType};"
}}
]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 关联组件
- 服务调用:x/nacosServiceCall
- 配置读取:x/nacosConfigGet
- 配置写入:x/nacosConfigSet
在 GitHub 上编辑此页 (opens new window)
上次更新: 2026/08/01, 05:05:14