Open Whathecode opened 2 years ago
This may also be important to safeguard that a repository update and matching domain event which is published occur as one transaction.
Currently, if a repository call succeeds, but an event bus call fails before it reaches a messaging bus, the system will end up in an inconsistent state.
To safeguard against concurrent repository updates overwriting each other's changes, a
version
field was introduced in all snapshots that are expected to be updated atomically in repository updates.Could even more guidance be given, and potentially specific database technologies for transaction management be used, by implementing a unit of work pattern on repository interfaces?
For example, MongoDB has read isolation, which if units of work get communicated to repository calls, could be used to achieve the same as verifying the
version
field.