开发者

CQRS How to handle tasks of users / Stale data

开发者 https://www.devze.com 2023-04-12 10:27 出处:网络
I understand that data is always stale. What is a way to handle a workflow task, like Approve Invoice. This task is allowed to execute once by the user. When this is processed by an async service it

I understand that data is always stale.

What is a way to handle a workflow task, like Approve Invoice. This task is allowed to execute once by the user. When this is processed by an async service it can take some seconds (or longer). In the meantime the user can a开发者_开发技巧pprove the same invoice again, because the task is not updated yet in the DB.

Any ideas about this are appreciated.


The domain model must enforce consistency. The model on the write side should not be considered stale, only the projections on the read side.

It doesn't matter if the approval event hasn't been projected into the read model. But if the user sends an invalid command based on stale data, the domain model needs to know that the approval had already happened.

Your domain's repository should always get the aggregate root in its lates state (no matter if you use event sourcing or some state-based persistence as a SQL db).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号