在将传入消息转发到下一Rule节点之前,延迟可配置的一段时间。
配置
- Use period in seconds pattern(使用以秒为单位的延迟模式) - 启用时,使用 Period in seconds pattern 从消息元数据或数据中提取延迟时长。禁用时,使用固定的 Period in seconds 字段
- Period in seconds(延迟秒数) - 固定延迟时长(秒)
- Period in seconds pattern(延迟秒数模式) - 从消息元数据或数据中提取延迟时长的模式(如
${metadataKey}或$[dataKey])
- Maximum pending messages(最大待处理消息数) - 可保留在内存中等待延迟超时的最大消息数
JSON Schema
消息处理算法
- 节点检查待处理消息数是否低于配置的最大限制
- 若超出限制,处理失败,消息路由至
Failure连接
- 若超出限制,处理失败,消息路由至
- 延迟时长确定:
- 若 Use period in seconds pattern 已启用:使用配置的模式从消息元数据或数据中提取延迟时长
- 若模式提取失败或值无法解析为整数:处理失败,消息路由至
Failure连接 - 若禁用模式:使用固定的 Period in seconds 配置值
- 消息延迟处理:
- 将消息在内存中存储计算出的延迟时长
- 延迟时长到期后,将原始消息转发至
Success连接 - 原始消息立即被确认
输出连接
Success- 消息延迟超时已到期,消息正在被转发
Failure- 超出最大待处理消息数限制
- 无法从元数据/数据模式解析延迟时长
- 发生其他意外错误
示例
示例1 — 固定延迟时长
传入消息
任意消息。
节点配置
1
2
3
4
5
{
"periodInSeconds": 5,
"useMetadataPeriodInSecondsPatterns": false,
"maxPendingMsgs": 1000
}
结果
消息将延迟5秒,然后转发至 Success。
示例2 — 从元数据动态延迟
传入消息
元数据:
1
2
3
{
"delaySeconds": "10"
}
节点配置
1
2
3
4
5
{
"useMetadataPeriodInSecondsPatterns": true,
"periodInSecondsPattern": "${delaySeconds}",
"maxPendingMsgs": 1000
}
结果
消息将延迟10秒(从元数据提取),然后转发至 Success 连接。
示例3 — 从消息数据动态延迟
传入消息
数据:
1
2
3
{
"waitTime": "3"
}
节点配置
1
2
3
4
5
{
"useMetadataPeriodInSecondsPatterns": true,
"periodInSecondsPattern": "$[waitTime]",
"maxPendingMsgs": 1000
}
结果
消息将延迟3秒(从消息数据提取),然后转发至 Success 连接。
示例4 — 超出最大待处理消息数
传入消息
任意消息。
节点配置
1
2
3
4
5
{
"periodInSeconds": 60,
"useMetadataPeriodInSecondsPatterns": false,
"maxPendingMsgs": 5
}
系统状态
- 已有5条消息处于延迟中
传出消息
消息路由至 Failure 连接。
结果
由于超出待处理消息限制,处理失败并返回错误。
示例5 — 无效延迟模式
传入消息
元数据:
1
2
3
{
"someOtherKey": "value"
}
节点配置
1
2
3
4
5
{
"useMetadataPeriodInSecondsPatterns": true,
"periodInSecondsPattern": "${invalidKey}",
"maxPendingMsgs": 1000
}
结果
由于指定模式解析为 ${invalidKey} 且无法解析为整数,处理失败并抛出运行时异常。