Always anticipate that there will be FAILURES. Identify and address the Failure points in your applications
Assume that there will be failures in replication
Assume there will be relication lag between source and target leading to stale data reads from target side
MUST handle:
Scenario Write side updates the state of an aggregate in the database. There is a failure in emitting the event. As a result the Read side is unaware of the state change; now the 2 ends are inconsistent !!!
Options
Reliable Messaging Pattern
Write domain object data & event data in the database with a local transaction and replay the events against queueing system in a separate | subsequent step.
Illustration depicts the logic in which event metadata is maintained in a MongoDb database. When event is received, Read side checks the metadata before applying the event.