RuleGo RuleGo
🏠首页
  • 快速入门
  • 规则链
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 可视化
  • RuleGo-Server
  • AOP
  • 触发器
  • 高级主题
  • 性能
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 流式计算
  • 组件市场
  • 概述
  • 快速入门
  • 路由
  • DSL
  • API
  • Options
  • 组件
🔥编辑器 (opens new window)
  • 可视化编辑器 (opens new window)
  • RuleGo-Server (opens new window)
  • 🌊StreamSQL
  • 🤖智能体框架
  • 🦀TPCLAW 智能体平台 (opens new window)
  • ❓问答

    • FAQ
💖支持
👥加入社区
  • Github (opens new window)
  • Gitee (opens new window)
  • GitCode (opens new window)
  • 更新日志 (opens new window)
  • English
  • 简体中文
🏠首页
  • 快速入门
  • 规则链
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 可视化
  • RuleGo-Server
  • AOP
  • 触发器
  • 高级主题
  • 性能
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 流式计算
  • 组件市场
  • 概述
  • 快速入门
  • 路由
  • DSL
  • API
  • Options
  • 组件
🔥编辑器 (opens new window)
  • 可视化编辑器 (opens new window)
  • RuleGo-Server (opens new window)
  • 🌊StreamSQL
  • 🤖智能体框架
  • 🦀TPCLAW 智能体平台 (opens new window)
  • ❓问答

    • FAQ
💖支持
👥加入社区
  • Github (opens new window)
  • Gitee (opens new window)
  • GitCode (opens new window)
  • 更新日志 (opens new window)
  • English
  • 简体中文

广告采用随机轮播方式显示 ❤️成为赞助商
  • 快速入门

  • 规则链

  • 标准组件

  • 扩展组件

    • 扩展组件概述
    • 过滤器

    • 动作

    • 转换器

    • 外部的

    • ai

    • CI

    • IoT

    • 流式计算

    • 服务发现

      • 服务发现组件概览
      • 服务调用

      • 配置

        • Nacos 配置获取
        • Nacos 配置监听端点
          • 配置
          • 触发消息
          • 示例
          • 关联组件
        • Nacos 配置写入
    • 文件

  • 自定义组件

  • 组件市场

  • 可视化

  • AOP

  • 触发器

  • 高级主题

  • 智能体框架

  • RuleGo-Server

  • 问题

目录

Nacos 配置监听端点

endpoint/nacos 端点:订阅 nacos 配置,配置变更自动触发规则链。路由 from.path 填 nacos Data ID(逗号分隔可监听多个)。

需要额外引入扩展库:rulego-components-discovery (opens new window)

# 配置

继承 公共连接配置,额外字段:

字段 类型 说明 默认值
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

# 关联组件

  • 服务调用:x/nacosServiceCall
  • 配置读取:x/nacosConfigGet
  • 配置写入:x/nacosConfigSet
在 GitHub 上编辑此页 (opens new window)
上次更新: 2026/08/01, 05:05:14
Nacos 配置获取
Nacos 配置写入

← Nacos 配置获取 Nacos 配置写入→

Theme by Vdoing | Copyright © 2023-2026 RuleGo Team | Apache 2.0 License

  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式