知识卡片
Outbox事务避免漏事件
Outbox把业务状态修改与待发事件记录放进同一数据库事务,两者一起成功或回滚。发布器读取待发记录,确认代理接收后再清理。若确认后、清理前故障,重启会重复发布,所以这是至少一次模式,需要幂等消费和可恢复进度;它保证留有可发送事实,不会自动让数据库与消息代理形成分布式原子提交。
结构图:
flowchart LR
A[业务事务] --> B[修改业务状态]
A --> C[写入Outbox]
C --> D[发布器读取]
D --> E[事件代理确认]
E --> F[删除待发项]
业务状态与Outbox在同一数据库事务内;代理确认与删除不是同一原子事务,失败后可重复发布。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Integrating Event-Driven Architectures with Existing Systems · 查看原书依据
Both the internal table updates and the outbox updates must be bundled into a single transaction, such that each occurs only if the entire transaction succeeds. A failure to do may eventually result in divergence with the event stream as the single source of truth, which can be difficult to detect and repair. This pattern is a more invasive approach to change-data capture as it requires modification to either the
参考来源
- 位置:《Building Event-Driven Microservices Leveraging Organizational Data at Scale (Adam Bellemare)》第04章《Integrating Event-Driven Architectures with Existing Systems》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Building Event-Driven Microservices Leveraging Organizational Data at Scale (Adam Bellemare)/_epub-src/OEBPS/ch04.xhtml;规范化段落起句:Both the internal table updates and the outbox)
- 结论依据:原文对该对象的定义、运行说明或对比支持以下归纳:Outbox把业务状态修改与待发事件记录放进同一数据库事务,两者一起成功或回滚。本卡同时保留其适用条件与失败边界。
- 原始内容:Both the internal table updates and the outbox updates must be bundled into a single transaction, such that each occurs only if the entire transaction succeeds. A failure to do may eventually result in divergence with the event stream as the single source of truth, which can be difficult to detect and repair. This pattern is a more invasive approach to change-data capture as it requires modification to either the