Multiple Aggregates Root INSTANCES per transaction

最后都变了- 提交于 2019-12-05 04:25:37

I think an AR may be more about the consistency boundary than the transaction boundary.

The fact that a transaction happens to fit nicely around an AR boundary is just coincidence.

Since transactions are more of an application layer concern, if you end up with more than one AR in a transaction then it does not necessarily indicate a design issue.

In fact, I would go so far as to say that in some 100% consistency requirement scenarios you may not even have a choice but to include all changes in one transaction.

Say you happen to be working with CQRS in an Async model then most likely your aggregate boundaries will become the only aggregate changed within that transaction. Now that is completely the opposite if you are using CQRS in a sync model or even if you are doing RPC N-Tier development style, where in a client call a good few changes are performed against you data model. In this last case scenario, you will definitely have multiple instances of aggregates within the same transaction (i.e.: unit of work with transaction scope).

I don´t think there is a right or wrong answer to your question without knowing more about the architecture of your system. DDD on its own cannot set the rules for your system wide transactions. What I can say for sure, is, if you happen to be using an async, event based system with cqrs and happen to be changing more than one aggregate per transaction, then, and this is just my opinion, something does not seem to be right.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!