Blog Logo
TAGS

Outboxer - A Simple and Broker Agnostic Implementation of Outbox Pattern with Entity Framework

Outboxer is a library available at Nuget that provides a simple and broker agnostic Outbox Pattern implementation. To use Outboxer, you need to use Entity Framework as it uses its built-in Unit-Of-Work to assure everything is saved at the same time and guarantee consistency. To get started with Outboxer, you need to make sure that your DbContext inherits `OutboxerContext` and create the outbox table using `dotnet ef migrations add`/`dotnet ef database update`. After that, you can register Outboxer using `services.AddOutboxer();` and implement your own broker communication mechanism by implementing the `IBrokerPublisher` interface. Once youve done that, you can register your custom broker communication class on the DI container using `services.AddScoped()` and publish a message using `IPublisher` interface and the `Publish` method. Its important to note that if the BackgroundWorker that sends the messages gets restarted, it will re-enqueue ALL the messages in the outbox table that have ENQUEUED status. Therefore, its a good idea to implement idempotency at your consumers.