RuleGo RuleGo
🏠Home
  • Quick Start
  • Rule Chain
  • Standard Components
  • Extension Components
  • Custom Components
  • Visualization
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • Trigger
  • Advanced Topics
  • Performance
  • Standard Components
  • Extension Components
  • Custom Components
  • Components Marketplace
  • Overview
  • Quick Start
  • Routing
  • DSL
  • API
  • Options
  • Components
🔥Editor (opens new window)
  • RuleGo Editor (opens new window)
  • RuleGo Server (opens new window)
  • StreamSQL
  • Github (opens new window)
  • Gitee (opens new window)
  • Changelog (opens new window)
  • English
  • 简体中文
🏠Home
  • Quick Start
  • Rule Chain
  • Standard Components
  • Extension Components
  • Custom Components
  • Visualization
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • Trigger
  • Advanced Topics
  • Performance
  • Standard Components
  • Extension Components
  • Custom Components
  • Components Marketplace
  • Overview
  • Quick Start
  • Routing
  • DSL
  • API
  • Options
  • Components
🔥Editor (opens new window)
  • RuleGo Editor (opens new window)
  • RuleGo Server (opens new window)
  • StreamSQL
  • Github (opens new window)
  • Gitee (opens new window)
  • Changelog (opens new window)
  • English
  • 简体中文

广告采用随机轮播方式显示 ❤️成为赞助商
  • Quick Start

  • Rule Chain

  • Standard Components

    • Standard Components Overview
    • common

      • Node Reference
      • groupAction
      • iterator
      • for
      • fork
      • join
      • Switch
      • Inclusive
        • Configuration
        • Relation Type
        • Execution Result
        • Comparison with Switch
        • Configuration Example
      • Break
      • End Node
    • filter

    • action

    • transform

    • external

    • flow

  • Extension Components

  • Custom Components

  • Components marketplace

  • Visualization

  • AOP

  • Trigger

  • Advanced Topic

  • RuleGo-Server

  • FAQ

  • Endpoint Module

  • Support

  • StreamSQL

目录

Inclusive

The inclusive component routes to all matched branches. Unlike switch, which stops at the first matched case, inclusive evaluates all configured cases and forwards the message to each relation whose expression evaluates to true. If none matches, it routes to the Default relation. If expression evaluation fails, it routes to Failure.

# Configuration

Field Type Description Default
cases List of Case List of case expressions None

Case:

Field Type Description Default
case string Conditional expression None
then string Relation name None

Expressions use the expr (opens new window) engine and support variables:

  • id – message ID
  • ts – message timestamp (ms)
  • data – original message content
  • msg – message body, access as msg.field when dataType is JSON
  • metadata – message metadata, e.g., metadata.customerName
  • type – message type
  • dataType – data type

Examples:

  • msg.temperature > 50
  • msg.temperature > 50 && metadata.customerName == 'rulego'
  • upper(metadata.customerName[:4]) == 'GO'
  • replace(toJSON(msg),'name','productName')
  • msg.humidity >= 80 || msg.temperature >= 30

See more syntax and functions: expr language definition (opens new window)

# Relation Type

  • Case.then: When a case evaluates to true, the message is routed to the relation named by then (multiple branches may be routed simultaneously)
  • Default: When no case matches, the message is routed to Default
  • Failure: When expression evaluation fails, the message is routed to Failure

# Execution Result

This component is purely for routing; it does not modify msg, metadata, or msgType. For each matched case, the message is forwarded once. If none matches, it forwards to Default.

Implementation reference: in d:\github\rulego\components\common\inclusive_node.go:66, the component iterates all cases, collects matched relations, and calls TellNext with multiple relation types; otherwise it routes to Default.

# Comparison with Switch

  • switch (conditional branch): evaluates cases in order and stops at the first match, routing to a single branch.
  • inclusive (inclusive branch): evaluates all cases and routes to all matched branches; if none matches, routes to Default.
  • Error handling: identical; on evaluation error, routes to Failure.

# Configuration Example

{
  "ruleChain": {
    "id": "inc-01",
    "name": "Inclusive Branch Demo",
    "debugMode": true,
    "root": true
  },
  "metadata": {
    "endpoints": [],
    "nodes": [
      {
        "id": "node_inclusive",
        "additionalInfo": { "description": "", "layoutX": 480, "layoutY": 280 },
        "type": "inclusive",
        "name": "inclusive",
        "debugMode": false,
        "configuration": {
          "cases": [
            { "case": "msg.temperature>=20 && msg.temperature<=50", "then": "Case1" },
            { "case": "msg.temperature>50", "then": "Case2" }
          ]
        }
      },
      { "id": "node_case1", "additionalInfo": { "description": "", "layoutX": 840, "layoutY": 160 }, "type": "jsTransform", "name": "case1", "debugMode": false, "configuration": { "jsScript": "msg=msg||{}\nmsg.match='Case1'\nreturn {'msg':msg,'metadata':metadata,'msgType':msgType};" } },
      { "id": "node_case2", "additionalInfo": { "description": "", "layoutX": 840, "layoutY": 280 }, "type": "jsTransform", "name": "case2", "debugMode": false, "configuration": { "jsScript": "msg=msg||{}\nmsg.match='Case2'\nreturn {'msg':msg,'metadata':metadata,'msgType':msgType};" } },
      { "id": "node_default", "additionalInfo": { "description": "", "layoutX": 840, "layoutY": 380 }, "type": "jsTransform", "name": "default", "debugMode": false, "configuration": { "jsScript": "msg=msg||{}\nmsg.match='Default'\nreturn {'msg':msg,'metadata':metadata,'msgType':msgType};" } }
    ],
    "connections": [
      { "fromId": "node_inclusive", "toId": "node_case1", "type": "Case1" },
      { "fromId": "node_inclusive", "toId": "node_case2", "type": "Case2" },
      { "fromId": "node_inclusive", "toId": "node_default", "type": "Default" }
    ]
  }
}
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
Edit this page on GitHub (opens new window)
Last Updated: 2025/11/27, 10:15:33
Switch
Break

← Switch Break→

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

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