知识卡片
跨服务事务需要协调
跨服务事务涉及两个及以上服务合作完成一项业务,例如支付、订单状态、厨房排产和库存更新。各步骤分处不同进程,成功与失败结果必须协调,不能只检查单个服务的返回值。这里的“事务”指业务协作,不自动意味着具有数据库 ACID 原子性。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》第 1 章《What are microservice APIs?》(源文件:_epub-src/OEBPS/Text/01.htm)
- 结论依据:1.3.4 节直接定义分布式事务需至少两个服务协作,并以支付、订单状态、厨房和库存为例说明业务步骤相关且故障时需要协调。
- 原始内容:Distributed transactions are those that require the collaboration of two or more services. ... Process the payment. If payment is successful, update the order’s status to indicate that it’s in progress. Interface with the kitchen service to schedule the order for production. Update the stock of ingredients to reflect their current availability.