Outbox¶
This documentation will not dive into the pros/cons of the Outbox pattern, but merely offer Dafda's take on it.
The Outbox Pattern
For more information, see e.g. https://microservices.io/patterns/data/transactional-outbox.html
Dafda Outbox Implementation¶
Dafda offers a framework for implementing a custom Outbox, using whatever technology is required, as longs as a few key interfaces are implemented and configured. Whether dispatching of outbox message are handled in-process or out-of-band is entirely up to the Dafda client.
Below is a diagram over the moving parts:
The Service, e.g. an ASP.NET application, receives a command request that writes data to the domain model (the "Aggregate") in the relational database. Supplying a custom implementation of the IOutboxEntryRepository
interface, outbox messages should be persisted as part of the same transaction as the domain model. The Outbox processor will (either by notifications or timeouts) process the "unpublished" outbox messages, and produce those on the "Aggregate" Kafka topic.
Example¶
For a comprehensive example using ASP.NET Core, EF Core, and Postgres to persist outbox message, including an out-of-band outbox processor, take a look at the OutOfBandOutboxMessaging for the required configuration, and outbox_ddl.sql for the Postgresql schema.