RuleGo RuleGo
🏠首页
  • 快速入门
  • 规则链
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 可视化
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • 触发器
  • 高级主题
  • 性能
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 组件市场
  • 概述
  • 快速入门
  • 路由
  • DSL
  • API
  • Options
  • 组件
🔥编辑器 (opens new window)
  • 可视化编辑器 (opens new window)
  • RuleGo-Server (opens new window)
  • ❓问答

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

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

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

  • 规则链

  • 标准组件

  • 扩展组件

  • 自定义组件

  • 组件市场

  • 可视化

  • AOP

  • 触发器

    • 触发器
      • 说明
  • 高级主题

  • RuleGo-Server

  • 问题

目录

触发器

# 说明

RuleGo 触发规则链执行有两种方式:自动和手动。

  • 自动触发器我们称作:Endpoint (输入端点)。你可以在规则链DSL文件增加endpoint配置,动态设置输入端,通过外部触发源触发规则链执行。 例如:设置接受HTTP请求、MQTT\kafka订阅、定时等接入端点。

本版本目前还不能在规则链DSL中设置Endpoint复用,对于HTTP Endpoint如果端口占用,则无法再次使用。解决方案:Endpoint和规则链分离运行方式。Endpoint DSL

示例:

接受 /api/v1/test API请求,然后交给规则链节点处理其请求:

{
  "ruleChain": {
    "id": "withHttpEndpoint",
    "name": "内置Http输入端规则链"
  },

  "metadata": {
    "endpoints":[
      {
        "id": "e1",
        "type": "http",
        "name": "http server",
        "configuration": {
          "server": ":9090"
        },
        "routers": [
          {
            "id":"r1",
            "params": [
              "POST"
            ],
            "from": {
              "path": "/api/v1/test",
              "configuration": {
              }
            },
            "to": {
              "wait": true,
              "processors": ["responseToBody"]
            }
          }
        ]

      }
    ],
    "nodes": [
      {
        "type": "jsFilter",
        "name": "过滤",
        "debugMode": true,
        "configuration": {
          "jsScript": "return msg.temperature>10;"
        }
      }
    ],
    "connections": [

    ]
  }
}
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

每隔1秒触发规则链执行逻辑:

{
  "ruleChain": {
    "id": "withScheduleEndpoint",
    "name": "内置定时输入端规则链"
  },

  "metadata": {
    "endpoints":[
      {
        "id": "e2",
        "type": "schedule",
        "name": "schedule",
        "processors": ["testPrint"],
        "routers": [
          {
            "from": {
              "path": "*/1 * * * * *"
            }
          }
        ]
      }
    ],
    "nodes": [
      {
        "id":"s1",
        "type": "jsFilter",
        "name": "过滤",
        "debugMode": true,
        "configuration": {
          "jsScript": "return msg.temperature>10;"
        }
      }
    ],
    "connections": [

    ]
  }
}
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
36
37
38
  • 手动触发规则链,详细参考:执行规则链
在 GitHub 上编辑此页 (opens new window)
上次更新: 2025/03/31, 01:52:11
规则链初始化校验器切面
Config

← 规则链初始化校验器切面 Config→

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

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