← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 2285.l.10.a

先发事件会暴露未提交状态

理解等级:中级

聚合内直接发布事件时,订阅者可能先收到业务成功通知,但数据库尚未提交,甚至稍后因并发或技术故障回滚。消息无法随数据库回滚撤回,于是外部依据不存在的事实行动。领域事件的创建与对外发送必须区分,不能把“对象已变”当成“事务已提交”。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 通信模式 · 查看原书依据

      First, the event will be dispatched before the aggregate’s new state is committed to the database. A subscriber may receive the notification that the campaign was deactivated, but it would contradict the campaign’s state. Second, what if the database transaction fails to commit because of a race condition, subsequent aggregate logic rendering the operation invalid,

    参考来源

    - 位置:《Learning Domain-Driven Design》第9章《通信模式》(来源项目:book-sources;源文件:extracted/Learning Domain-Driven Design/_epub-src/OEBPS/ch09.html) - 结论依据:原文围绕本卡所述机制给出定义、适用条件及相关取舍,以下摘录为直接依据。 - 原始内容:First, the event will be dispatched before the aggregate’s new state is committed to the database. A subscriber may receive the notification that the campaign was deactivated, but it would contradict the campaign’s state. Second, what if the database transaction fails to commit because of a race condition, subsequent aggregate logic rendering the operation invalid,