CQRS Event Sourcing: Validate UserName uniqueness

前端 未结 8 1318
醉话见心
醉话见心 2021-01-29 18:08

Let\'s take a simple \"Account Registration\" example, here is the flow:

  • User visit website
  • Click \"Register\" button and fill form, click \"Save\" button
8条回答
  •  自闭症患者
    2021-01-29 18:50

    There is nothing wrong with creating some immediately consistent read models (e.g. not over a distributed network) that get updated in the same transaction as the command.

    Having read models be eventually consistent over a distributed network helps support scaling of the read model for heavy reading systems. But there's nothing to say you can't have a domain specific read model thats immediately consistent.

    The immediately consistent read model is only ever used to check data before issuing a command, you should never use it for directly displaying read data to a user (i.e. from a GET web request or similar). Use eventually consistent, scaleable read models for that.

提交回复
热议问题