This project demonstrates the implementation of the Outbox Pattern using MassTransit, EF Core, MediatR, and SignalR within a Clean Architecture structure. The Outbox Pattern ensures data consistency across distributed systems by persisting events in an outbox table and processing them asynchronously.
The project is organized according to the principles of Clean Architecture, with a clear separation of responsibilities:
- Api: Exposes HTTP endpoints for the application.
- Application Layer: Contains business logic, commands, event handlers, and services.
- Domain Layer: Defines core entities, domain events, and business rules.
- Infrastructure Layer: Implements data persistence, event publishing, and external service integration.
The Outbox Pattern ensures that events are published only when the database transaction is successful. Events are stored in an outbox table and processed asynchronously to maintain consistency.
MassTransit is used to handle message publishing and consumption. The project has two configurations:
- In-Memory Configuration: Consumes messages from the outbox table and routes them based on their type.
- RabbitMQ Configuration: Publishes application events to RabbitMQ for external distribution.
EF Core is used for data persistence and integrates with MassTransit to handle outbox messages automatically.
MediatR is used to process domain events internally within the application.
SignalR is used to send UI events in real time to connected clients.