What is the correct way of maintaining consistency boundaries with aggregate & Repository?

20 Views Asked by At

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,

  1. Update shopping cart API gets called.
  2. We will fetch the shopping cart aggregate from the repository.
  3. We will update the items inside the shopping cart.
  4. 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?

0

There are 0 best solutions below