-
Notifications
You must be signed in to change notification settings - Fork 21
Description
We already tested code on a private implementation of Repository to reduce ConcurrencyException. Using a ConcurrentDictinoary we can issue waits if another thread is using the same aggregate.
The idea is, if we have multi thread execution and three threads needs to issue a command on the same aggregate, if all three threads read the Aggregate at the same version, the first one that saves the aggregate will succeed but the other two will fail with a ConcurrencyException.
Before loading the Aggregate, the repository can check if other threads are working with the same Aggreagate and then sleep for a little while reducing the risk of ConcurrencyException.
This is even more useful when ICache will be implemented because avoiding exception will allow for the repository to immediately read from ram the new IMemento resulting from previous save.