知识卡片
事件驱动聚合状态变化
事件溯源领域模型的操作顺序是读取事件、重建聚合状态、执行命令生成新事件、提交新事件。命令不直接修改状态后补发事件,而是通过新事件驱动状态投影变化,保证每一次改变都有事实记录。普通领域模型也能发事件,区别在于是否由事件完整代表状态。
结构图:
flowchart TD
A[读取历史事件] --> B[顺序重建状态]
B --> C[执行业务命令]
C --> D[生成并应用新事件]
D --> E[按预期版本提交新事件]
相关:[[事件存储追加并验版本]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 建模时间维度 · 查看原书依据
Each operation on an event-sourced aggregate follows this script: Load the aggregate’s domain events. Reconstitute a state representation—project the events into a state representation that can be used to make business decisions. Execute the aggregate’s command to execute the business logic, and consequently, produce new domain events. Commit the new domain events to the event
参考来源
- 位置:《Learning Domain-Driven Design》第7章《建模时间维度》(来源项目:book-sources;源文件:extracted/Learning Domain-Driven Design/_epub-src/OEBPS/ch07.html)
- 结论依据:原文围绕本卡所述机制给出定义、适用条件及相关取舍,以下摘录为直接依据。
- 原始内容:Each operation on an event-sourced aggregate follows this script: Load the aggregate’s domain events. Reconstitute a state representation—project the events into a state representation that can be used to make business decisions. Execute the aggregate’s command to execute the business logic, and consequently, produce new domain events. Commit the new domain events to the event