【发布时间】:2021-01-26 13:12:26
【问题描述】:
在尝试学习事件溯源和 CQRS 时,我正在制作家谱应用程序。我的应用程序中有三个聚合:PersonAggregate、FactAggregate、FamilyAggregate。 我从 UI 到服务器的请求为一个人添加配偶是:
{
personId: "", // And Existing Person in the DB
personInput: {name: "Bob", birthDate: ""} // Input to create a new person in the DB
}
My Family Aggregate 监听 PersonAggregate 中的 PersonCreated 事件,以记录所有已创建的人。
UI 调用 PersonAggregate 来创建人(使用有关它的数据需要在两个人之间创建伙伴关系而不是调用 FamilyAggregate),然后在 PersonCreated 事件上将 FamilyAggregate 需要知道的数据添加为配偶吗?或者这是一个糟糕的设计,因为现在 Event 中有命令数据?
创建一个人时,Person Aggregate 还需要将数据发送到 FactAggregate 以创建有关此人生日的 Fact。
【问题讨论】:
标签: domain-driven-design cqrs event-sourcing