Skip to content

A sample of the transactional Outbox and Inbox patterns in C# and RabbitMQ.

License

Notifications You must be signed in to change notification settings

JMOrbegoso/OutboxInboxPatternSample

Repository files navigation

OutboxInboxPatternSample

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.

Requirements

  1. Docker
  2. Docker compose

Run sample

  1. Set-up the SQL Server database and RabbitMQ:
docker compose up
  1. Apply database schemas:
dotnet ef database update -p .\SenderApi\
dotnet ef database update -p .\Receiver\

Usage

  1. Run SenderApi project:
dotnet run --project .\SenderApi\
  1. Run OutboxProcessor project:
dotnet run --project .\OutboxProcessor\
  1. Run Receiver project:
dotnet run --project .\Receiver\
  1. Launch swagger in your web browser: https://localhost:7278/swagger/index.html

  2. Using Swagger or Postman make a HTTP POST to /Users.

Parts:

This sample consists of 3 projects:

  1. 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.

  2. OutboxProcessor: Worker, it read the Outbox database table and publish the unpublished ones to a RabbitMQ queue.

  3. Receiver: Worker, it is subscribed to the outbox RabbitMQ queue, and save them into the Inbox database table and handle them from there.