https://github.com/jmorbegoso/outboxinboxpatternsample
A sample of the transactional Outbox and Inbox patterns in C# and RabbitMQ.
https://github.com/jmorbegoso/outboxinboxpatternsample
api c-sharp docker docker-compose inbox-pattern message-queue outbox-pattern quarz rabbitmq sqlserver worker
Last synced: 11 months ago
JSON representation
A sample of the transactional Outbox and Inbox patterns in C# and RabbitMQ.
- Host: GitHub
- URL: https://github.com/jmorbegoso/outboxinboxpatternsample
- Owner: JMOrbegoso
- License: gpl-3.0
- Created: 2022-07-24T01:14:32.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-14T16:49:00.000Z (over 3 years ago)
- Last Synced: 2025-01-17T06:09:55.590Z (about 1 year ago)
- Topics: api, c-sharp, docker, docker-compose, inbox-pattern, message-queue, outbox-pattern, quarz, rabbitmq, sqlserver, worker
- Language: C#
- Homepage:
- Size: 87.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/MassTransit/MassTransit) or [NServiceBus](https://github.com/Particular/NServiceBus).
## Requirements
1. Docker
2. Docker compose
## Run sample
1. Set-up the SQL Server database and RabbitMQ:
```BASH
docker compose up
```
2. Apply database schemas:
```BASH
dotnet ef database update -p .\SenderApi\
dotnet ef database update -p .\Receiver\
```
## Usage
1. Run **SenderApi** project:
```BASH
dotnet run --project .\SenderApi\
```
2. Run **OutboxProcessor** project:
```BASH
dotnet run --project .\OutboxProcessor\
```
3. Run **Receiver** project:
```BASH
dotnet run --project .\Receiver\
```
4. Launch swagger in your web browser:
https://localhost:7278/swagger/index.html
5. 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.