Create the option within the same project to use messaging with Rebus, MassTransit, or NServiceBus.
This project aims to demonstrate the implementation of the following technologies and architectural patterns:
- API (.NET)
- Patterns: DDD, EDD, CQRS
- NServiceBus using Saga (RabbitMQ)
- Redis
- FluentValidation
- MediatR
- Entity Framework
- Angular
- PostgreSQL
- Docker
- ...
The solution is composed of four services:
- Product -- Simple product registration using Redis for caching.
- Stock -- Simple service responsible for adding products to stock.
- Sale -- Simple service responsible for creating a sale.
Process (using messaging via MassTransit, Rebus, or NServiceBus implemented with Saga):
-
Sends a message to the Stock service.
-
The Stock service checks whether the requested items are available in stock.
-
If available:
- Sends a message to Sale indicating that stock is available.
- Sends a message to Payment.
-
If not available:
- Sends a message to Sale indicating stock failure.
- Ends the process.
-
Payment simulates a payment result (success or failure). In both cases, it returns a message to Sale and ends the process.
-
Payment -- Simulates payment success or failure and sends a message to Sale.
-
Mini framework -- A small framework was created to support the messaging implementation.
- Build the backend
-
Navigate to the folder
src/backend/srcand run:docker-compose up --build
-
- Build the frontend
-
Navigate to the folder
src/frontend/appclientangularand run:docker build -t app-client -f Dockerfile .
-
- Run database migrations
-
Navigate to
src/backend/src/Shared/Shared.Infrastructureand run:dotnet ef migrations add InitialCreate dotnet ef database update
-
- Start the containers
-
In the WebApi projects (Sale, Stock, Payment) configure which messaging framework should be used. For example:
-
If using MassTransit, add a reference to:
Stock.Infrastructure.MassTransit -
If using Rebus, add a reference to:
Stock.Infrastructure.Rebus -
If using NServiceBus, add a reference to:
Stock.Infrastructure.NServiceBus
-
-
In
appsettings.json, define which messaging framework should be used.
- Create an orchestrator to define which messaging framework should be used without needing to manually reference the project, or create separate workers and an orchestrator that selects the messaging system before starting the project.
- Create IoC container configuration
- Add more queries using SignalR
- Add other frontend technologies such as Blazor and Next.js
- Improvement: the final solution would include specific workers for each messaging framework and an orchestrator responsible for selecting the messaging implementation
