Why is the CQRS repository publishing events, not the event store?

前端 未结 2 534
南方客
南方客 2020-12-28 10:15

According to http://cre8ivethought.com/blog/2009/11/12/cqrs--la-greg-young the component responsible for publishing events using an event publisher is the repository.

<
相关标签:
2条回答
  • 2020-12-28 10:42

    Your domain model is unaware of the storing mechanism. On the other hand it must make sure that the appropriate events will be published, no matter if you use an event store, a classical SQL store, or any other means of persistence.

    If you rely on the event store to publish the events you'd have a tight coupling to the storage mechanism.

    0 讨论(0)
  • 2020-12-28 10:44

    Storing and publishing the event must an atomic instruction because if one of both actions fails, the listeners of this event will be out of sync with the producer of the event.

    There is a another (more expensive) solution, compared to publishing the event from the event store, which is to use 2pc transactions (two-phases commit).

    you can find some more intereting information here: https://cqrs.wordpress.com/documents/building-event-storage/

    0 讨论(0)
提交回复
热议问题