中断(break)
break组件:用于在for循环节点中中断后续迭代。当消息经过该节点时,组件会在消息元数据中写入中断标记,循环节点检测到该标记后立即停止迭代并返回。
# 配置
该组件无配置项。
# 原理
组件在消息metadata中设置中断标记:_break=1,供for循环节点在每次迭代后检测。检测到标记后,循环节点会清除该标记并停止迭代。
# Relation Type
- Success: 始终转发到
Success关系,便于上游循环节点继续执行其控制逻辑(包括检测中断) - Failure: 无
# 执行结果
不修改msg与msgType;仅在metadata中写入中断标记_break=1。
# 配置示例
以下示例在遍历数组时,当满足条件时触发中断:
{
"ruleChain": {
"id": "break-01",
"name": "for循环中断示例",
"debugMode": true,
"root": true
},
"metadata": {
"nodes": [
{ "id": "n_for", "type": "for", "name": "遍历", "configuration": { "range": "msg.items", "do": "n_check", "mode": 1 } },
{ "id": "n_check", "type": "switch", "name": "条件分支", "configuration": { "cases": [ { "case": "msg.value>50", "then": "Stop" } ] } },
{ "id": "n_break", "type": "break", "name": "中断" }
],
"connections": [
{ "fromId": "n_check", "toId": "n_break", "type": "Stop" },
{ "fromId": "n_for", "toId": "n_check", "type": "Success" }
]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
在 GitHub 上编辑此页 (opens new window)
上次更新: 2025/11/27, 10:15:33