In CQRS, how do you build the response when creating an entity?

前端 未结 5 1897
心在旅途
心在旅途 2021-01-12 22:02

If using CQRS and creating an entity, and the values of some of its properties are generated part of the its constructor (e.g. a default active value for the

5条回答
  •  独厮守ぢ
    2021-01-12 22:08

    According to my understanding of CQRS, you cannot query the aggregate and the command handler could not return any value. The only permitted way of interogating the aggregate is by listening to the raised events. That you could do by simply querying the read model, if the changes are reflected synchronously from the events to the read model.

    In the case the changes to the read model are asynchronous things get complicated but solutions exists.

    Note: the "command handler" in my answer is the method on the Aggregate, not some Application layer service.

提交回复
热议问题