Files
wms-saas/docs/08-queue-scheduler.md
T
2026-09-29 13:08:21 +08:00

47 lines
829 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 08 Queue / Scheduler
## Queue
以下任务原则上应进入 Queue:
- 第三方订单同步
- 库存同步
- 物流同步
- 批量导入
- 批量导出
- 面单生成
- Tracking 同步
- 大量库存计算
- 报表生成
- AI 分析
- 邮件 / 通知
- Webhook 处理
**不要让用户 HTTP 请求长时间等待第三方 API。**
Job 要求:
- 携带 `tenant_code`,执行时恢复 TenantContext。
- 幂等:重复执行不会产生重复业务数据或重复扣减库存。
- 配置合理的重试次数、退避与超时。
## Scheduler
使用 Laravel Scheduler,例如:
- 订单同步
- 库存同步
- Tracking 同步
- 异常订单检查
- 库存预警
- AI 分析任务
- 报表任务
所有定时任务必须可配置,并考虑:
- 防重复执行
- 失败重试
- 日志
- 超时
- 租户隔离