Wait 任务
Wait 任务用于在工作流程中引入延迟或等待特定时间。它可以用于实现定时执行、延迟处理或基于时间的业务逻辑。
核心特性
时间控制
- 固定时间等待
- 动态时间计算
- 定时执行
时间表达式
- ISO 时间格式
- 相对时间计算
- 时区处理
执行控制
- 超时管理
- 取消机制
- 恢复处理
任务参数
参数 | 描述 | 必需/可选 |
---|---|---|
until | 等待截止时间,支持 ISO 格式日期时间或表达式 | 必需 |
duration | 等待时长(毫秒),与 until 二选一 | 必需 |
timeoutSeconds | 最大等待时间(秒) | 可选 |
timeZone | 时区设置,默认为 UTC | 可选 |
配置示例
1. 基础等待任务
{
"name": "wait_task",
"taskReferenceName": "wait_task_ref",
"type": "WAIT",
"inputParameters": {
"duration": "PT10M"
}
}
2. 定时执行任务
{
"name": "scheduled_task",
"taskReferenceName": "scheduled_task_ref",
"type": "WAIT",
"inputParameters": {
"until": "2024-12-31T23:59:59Z",
"timeZone": "Asia/Shanghai"
}
}
3. 动态等待时间
{
"name": "dynamic_wait",
"taskReferenceName": "dynamic_wait_ref",
"type": "WAIT",
"inputParameters": {
"duration": "${workflow.input.waitTime}",
"timeoutSeconds": 3600
}
}
使用场景
1. 延迟处理
{
"name": "delayed_processing",
"taskReferenceName": "delayed_processing_ref",
"type": "WAIT",
"inputParameters": {
"duration": "PT1H",
"timeoutSeconds": 4000,
"reason": "Allow system cool down"
}
}
2. 定时任务调度
{
"name": "scheduled_job",
"taskReferenceName": "scheduled_job_ref",
"type": "WAIT",
"inputParameters": {
"until": "${workflow.input.scheduledTime}",
"timeZone": "${workflow.input.timeZone}",
"jobDetails": {
"jobType": "maintenance",
"priority": "normal"
}
}
}
最佳实践
时间设置
- 使用标准格式
- 考虑时区影响
- 设置合理超时
错误处理
- 超时处理
- 取消处理
- 异常恢复
资源管理
- 控制等待数量
- 监控资源使用
- 优化调度策略
性能优化
等待管理
- 合理设置时间
- 避免过多等待
- 优化调度逻辑
资源利用
- 减少资源占用
- 并行处理优化
- 系统负载均衡
调试技巧
等待状态追踪
{ "inputParameters": { "debug": { "waitTaskId": "${TASK_ID}", "startTime": "${system.currentTimeMillis}", "targetTime": "${workflow.input.until}" } } }
时间监控
{ "inputParameters": { "monitor": { "remainingTime": 0, "elapsedTime": 0, "status": "WAITING" } } }
错误处理
常见错误
时间错误
- 格式无效
- 时区错误
- 过期时间
执行错误
- 超时异常
- 取消失败
- 系统中断
错误响应
{
"status": "FAILED",
"error": "WAIT_TASK_ERROR",
"message": "Wait task execution failed",
"details": {
"waitTime": "2024-12-31T23:59:59Z",
"errorCode": "INVALID_TIME_FORMAT",
"errorMessage": "Invalid datetime format"
}
}
监控建议
时间指标
- 等待时长统计
- 完成时间分布
- 超时比率
性能指标
- 资源使用情况
- 系统负载
- 响应时间
安全考虑
时间验证
- 输入检查
- 范围限制
- 格式验证
资源保护
- 限制并发数
- 防止资源耗尽
- 系统保护
UI 配置指南
基本配置
- 设置等待时间
- 选择时区
- 配置超时
高级选项
- 取消策略
- 恢复机制
- 监控设置
监控面板
- 等待状态
- 时间统计
- 性能监控