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
  • 简体中文

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

  • 规则链

  • 标准组件

    • 标准组件概述
    • 过滤器

      • js脚本过滤器
      • 字段过滤器
      • 消息路由
        • 配置
        • Relation Type
        • 执行结果
        • 配置示例
        • 应用示例
      • js脚本路由
      • 过滤器组
      • 表达式过滤器
      • 并行网关
      • 条件分支
    • 动作

    • 转换器

    • 外部的

    • 流

  • 扩展组件

  • 自定义组件

  • 组件市场

  • 可视化

  • AOP

  • 触发器

  • 高级主题

  • RuleGo-Server

  • 问题

目录

消息路由

msgTypeSwitch组件:消息路由组件。根据传入的消息类型(msgType)将消息动态路由到一个或多个输出链。该组件可以根据消息类型实现消息的分流和条件路由。

# 配置

该组件无需配置参数。通过连接关系配置路由规则。

# Relation Type

  • msgType: 通过消息类型(msgType)与下一个节点连接,支持一个msgType连接到多个节点
  • Default: 当消息类型与所有已配置的msgType都不匹配时,消息将沿Default链路径继续传递
  • Failure: 组件执行出错时,消息将沿Failure链路径继续传递

# 执行结果

该组件是纯路由组件,不会修改传入的msg、metadata和msgType内容。仅根据msgType决定消息的路由方向。

# 配置示例

{
  "id": "s1",
  "type": "msgTypeSwitch",
  "name": "过滤"
}
1
2
3
4
5

# 应用示例

通过msgType路由到不同的节点进行处理。

{
  "ruleChain": {
    "id":"rule01",
    "name": "测试规则链-msgTypeSwitch",
    "root": true
  },
  "metadata": {
    "nodes": [
      {
        "id": "s1",
        "type": "msgTypeSwitch",
        "name": "过滤"
      },
      {
        "id": "s2",
        "type": "log",
        "name": "记录日志1",
        "configuration": {
          "jsScript": "return 'handle msgType='+ msgType+':s2';"
        }
      },
      {
        "id": "s3",
        "type": "log",
        "name": "记录日志2",
        "configuration": {
          "jsScript": "return 'handle msgType='+ msgType+':s3';"
        }
      },
      {
        "id": "s4",
        "type": "log",
        "name": "记录日志3",
        "configuration": {
          "jsScript": "return 'handle msgType='+ msgType+':s4';"
        }
      }
    ],
    "connections": [
      {
        "fromId": "s1",
        "toId": "s2",
        "type": "TEST_MSG_TYPE1"
      },
      {
        "fromId": "s1",
        "toId": "s3",
        "type": "TEST_MSG_TYPE1"
      },
      {
        "fromId": "s1",
        "toId": "s4",
        "type": "TEST_MSG_TYPE2"
      }
    ]
  }
}
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
51
52
53
54
55
56
57
在 GitHub 上编辑此页 (opens new window)
上次更新: 2025/04/02, 01:29:50
字段过滤器
js脚本路由

← 字段过滤器 js脚本路由→

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

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