知识卡片

支付系统案例卡 · 2285.l.22.a

唯一请求键去重扣款

理解等级:高级

为[[重复请求可能重复扣款]]提供幂等接口,应由客户端为一次操作生成唯一请求键,重复尝试沿用此键;收款服务持久记住请求并识别重复。业务载荷相同不能证明同一次意图,因而不能以卡号金额代替键。去重必须由执行副作用的服务支持,调用方无法弥补接口缺失。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 工作流引擎与集成挑战 · 查看原书依据

      In this case a typical strategy is to generate unique IDs in the client that are handed over to the credit card charging service. This service can then detect duplicates if it has its own state to remember calls. Stateless services face a challenge, as you might have to introduce dedicated state for duplicate detection. It is advisable not to rely on the business payload for detecting duplicates.

    参考来源

    - 位置:《Practical Process Automation》第9章《工作流引擎与集成挑战》(来源项目:book-sources;源文件:extracted/Practical Process Automation (Bernd Ruecker)/_epub-src/OEBPS/ch09.xhtml) - 结论依据:原文明确客户端生成并传递唯一ID,扣款服务保存请求状态以识别重复,同时警告不要依赖业务载荷去重;据此可区分一次操作的重试与相同金额的多次合法意图。 - 原始内容:In this case a typical strategy is to generate unique IDs in the client that are handed over to the credit card charging service. This service can then detect duplicates if it has its own state to remember calls. Stateless services face a challenge, as you might have to introduce dedicated state for duplicate detection. It is advisable not to rely on the business payload for detecting duplicates.