You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
How to solve theDual Write problem using theOutbox Pattern with a pull and publish scheduler.
Dual Write problem
This project is a simple solution for theDual Write problem.
TheDual Write problem happens when:
the application needs to write to two different systems in a single transaction
the systems have different transactional boundaries
if one of the writes fails, the other write can't be rolled back, leaving the system in an inconsistent state
Example:
Write to a database and to a message broker.
TheDual Write problem can be solved using theOutbox Pattern, which makes sure that if one of the writes fails, the system can still recover the state inside the transaction and roll back all the writes.
Outbox Pattern implementation
There are probably different ways to implement theOutbox Pattern, but this simple project implements it using:
a database table calledoutbox that contains all the messages that need to be sent to the message broker
a scheduled task that reads the messages from theoutbox table and sends them to the message broker
Then, once a service needs to write to theorders table, for example, it also writes to theoutbox table in the same transaction.