【发布时间】:2020-03-23 15:32:06
【问题描述】:
所以我在 微服务 环境中使用 NestJs 和 CQRS 和 DDD,其中 Eventstore 和 MySql 作为数据库。在 NestJS 中,为了发布事件,对象必须是 AggregateRoot 类型。因此,我以AggregateRoot 的类型将其保存到数据库后发布返回的对象。
我现在需要做的只是在Event 中按原样发布传入请求,其他服务将侦听该事件,而不需要它是AggregateRoot 类型。
示例:我有一个传入的Order 到Order-Microservice,其中包含其他微服务所需的对象(如Delivery-Microservice 和Assembly-Microservice)。我不需要将它保存在 order-ms 中就可以发布它,因为它包含我在 order-ms 中不一定需要的数据。
NestJs EventPublisher 要求对象的类型为 AggregateRoot。我应该如何将该事件发布到 EventStore?
【问题讨论】:
标签: domain-driven-design nestjs cqrs event-sourcing