返回主题:资源库与查询

知识卡片

普通读书笔记卡 · 1971.o.1.b.4.e.3.a.1

以查询解除处理事件写入争用

理解等级:中级

原书货运案例中,写入 Handling Event 还要更新 Cargo 的 Delivery History 集合,因此事件事务会碰到 Cargo 聚合的并发修改。重构把“历史包含哪些事件”改为由 Handling Event Repository 按 Cargo 查询:写事件只修改事件自身聚合,查询历史时再取相关事件。图7.6呈现这一关联实现。作者认为事件录入多、历史查询少时可能更高效;这是设计推断,并非实测。它接续[[创建事件还须维护历史回指]]暴露的争用。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第57章《原书第07章|Pause for Refactoring: An Alternative Design of the Cargo Aggregate》(源文件:_epub-src/0321125215_ch07lev1sec9.html;图7.6) - 结论依据:原文指出更新历史集合使 Cargo 聚合卷入事件事务;改为查询后,新增事件无需修改该聚合,并为事件建立仓储。 - 原始内容:The need to update Delivery History when adding a Handling Event gets the Cargo AGGREGATE involved in the transaction. If some other user was modifying Cargo at the same time, the Handling Event transaction could fail or be delayed. Entering a Handling Event is an operational activity that needs to be quick and simple, so an important application requirement is the ability to enter Handling Events without contention.