A sample of the transactional Outbox and Inbox patterns using C#, SQL Server and RabbitMQ.
Note: This project is just a proof of concept and is not production ready, in production you may use frameworks such as MassTransit or NServiceBus.
- Docker
- Docker compose
- Set-up the SQL Server database and RabbitMQ:
docker compose up
- Apply database schemas:
dotnet ef database update -p .\SenderApi\
dotnet ef database update -p .\Receiver\
- Run SenderApi project:
dotnet run --project .\SenderApi\
- Run OutboxProcessor project:
dotnet run --project .\OutboxProcessor\
- Run Receiver project:
dotnet run --project .\Receiver\
-
Launch swagger in your web browser: https://localhost:7278/swagger/index.html
-
Using Swagger or Postman make a HTTP POST to /Users.
This sample consists of 3 projects:
-
SenderApi: API project, when a new user is created, it stores an Outbox message in the same transaction than the business database using the Unit of Work pattern.
-
OutboxProcessor: Worker, it read the Outbox database table and publish the unpublished ones to a RabbitMQ queue.
-
Receiver: Worker, it is subscribed to the outbox RabbitMQ queue, and save them into the Inbox database table and handle them from there.