Let's suppose, I have one aggregate ShoppingCart, Now the business constraint is, that people can modify shopping cart items concurrently, but shopping carts should be in a consistent state all the time.
Now, the usual workflow will be something like below,
- Update shopping cart API gets called.
- We will fetch the shopping cart aggregate from the repository.
- We will update the items inside the shopping cart.
- We will save the shopping cart aggregate inside the repository.
But, this is a classic fetch & update operation, which can lead to consistency issues.
So, how we can make this design better?