A small .NET 10 project for practicing asynchronous order processing, RabbitMQ messaging, and safe message redelivery.
POST /api/orderssaves an order with thePendingstatus and publishesOrderCreatedthrough the transactional outbox.- The inventory consumer reserves stock and publishes either
InventoryReservedorInventoryReservationFailed. - A successful reservation starts a simulated payment.
PaymentCompletedchanges the order status toConfirmed. - A failed reservation changes the order status to
Cancelled.
Order reads use Redis with the cache-aside pattern. Inventory reservations are idempotent per OrderId.
- .NET 10 / ASP.NET Core
- EF Core / PostgreSQL
- MassTransit / RabbitMQ
- Redis
- xUnit / NSubstitute
- Docker Compose
Requirements: Docker.
docker compose up --buildThis starts PostgreSQL, Redis, RabbitMQ and the API. The API waits for the dependencies to become healthy and applies EF Core migrations on startup.
- Swagger: http://localhost:5173/swagger
- Liveness: http://localhost:5173/health/live
- Readiness: http://localhost:5173/health/ready
- RabbitMQ Management: http://localhost:15672 (
guest/guest)
Database data lives in the named postgres_data volume and survives
docker compose down. Use docker compose down -v to remove that volume and
drop the database.
Requirements: .NET 10 SDK and Docker.
docker compose up -d postgres redis rabbitmq
dotnet run --project src/OrderFlow.Api --launch-profile httpExample request:
POST http://localhost:5173/api/orders
Content-Type: application/json
{
"items": [
{
"productId": "11111111-1111-1111-1111-111111111111",
"quantity": 1
}
]
}dotnet test OrderFlow.sln