我正在阅读 Adam Bellemare 所著的《构建事件驱动的微服务》一书,有一部分我不明白:
In the perfect world, all state would be created, managed, maintained, and restored from the single source of truth of the event streams. Any shared state should be published to the event broker first and materialized back to any services that need to materialize the state, including the service that produced the data in the first place..
(第 55 页)
如果我拥有所需的所有数据,为什么不更新相关域表,然后附加到同一事务中的发件箱表?必须使用从事件流返回的数据似乎有点麻烦。
我理解 EDM 的原则,即流应该是事实的单一来源,但我想知道我是否误解了这里的某些内容,并且希望对书中上述片段进行解释/解释。
谷歌搜索,但没有找到任何东西
好吧,没有人阻止你这样做。但发件箱模式解决了另一个问题。
当然,如果您有单个有界上下文,您会认为发件箱表与事件流相同(实际上并非如此,因为它不一定跨越所有领域事件,仅跨越集成事件)。但请记住,每个人的目标和实施方式都不同。