Step 01 — Create the project
What you'll do: create a .NET 10 solution with an empty Orders API, and start PostgreSQL and RabbitMQ in Docker.
By the end of the guide you will have built this (today you start with the Orders.Api box and the containers):
Steps
Install the tools.
Tool Version Why .NET SDK 10.0 builds and runs the apps Docker Desktop (or another Docker engine) any recent runs PostgreSQL and RabbitMQ curl any calls the API Create the folder, pin the SDK and create the solution. The
.slnxformat is the new, short XML solution file that .NET 10 uses by default.bashmkdir outbox-inbox-pattern-guide && cd outbox-inbox-pattern-guide dotnet new globaljson --sdk-version 10.0.401 --roll-forward latestFeature dotnet new gitignore dotnet new sln --name OutboxInbox --format slnx dotnet new web -o src/Orders.Api -n Orders.Api dotnet sln OutboxInbox.slnx add src/Orders.Api/Orders.Api.csprojglobal.jsonpins the SDK so everyone on the team builds with the same compiler.rollForward: latestFeaturestill accepts newer 10.0 feature bands.Move the settings every project shares into Directory.Build.props at the root. MSBuild picks this file up for every project below it, so each
.csprojstays almost empty.xml<PropertyGroup> <TargetFramework>net10.0</TargetFramework> <LangVersion>latest</LangVersion> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> </PropertyGroup>Delete the same four properties from Orders.Api.csproj; only the
<Project Sdk="Microsoft.NET.Sdk.Web">element is left.Give the API a fixed port. In launchSettings.json set the
httpprofile tohttp://localhost:5080(and thehttpsprofile tohttps://localhost:7080), and setlaunchBrowsertofalse: this is an API, not a web page.Replace Program.cs with a root endpoint that names the service:
csharpvar builder = WebApplication.CreateBuilder(args); var app = builder.Build(); if (!app.Environment.IsDevelopment()) { app.UseHsts(); app.UseHttpsRedirection(); } app.MapGet("/", () => TypedResults.Ok(new { service = "Orders.Api" })); app.Run();Outside Development the API forces HTTPS. Locally you call it over plain HTTP to keep the curl commands short.
Add the containers. docker-compose.yml starts one PostgreSQL and one RabbitMQ, with pinned image tags and health checks:
yamlservices: postgres: image: postgres:17.12-alpine environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres # local development password, not a secret ports: - "5433:5432" # 5433 on the host, so it never clashes with a PostgreSQL you already run on 5432 volumes: - postgres-data:/var/lib/postgresql/data - ./docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql:ro healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres -d shipping"] rabbitmq: image: rabbitmq:4.4.1-management ports: - "5672:5672" # AMQP, used by the apps - "15672:15672" # management UI healthcheck: test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]docker/postgres/init.sql runs the first time the volume is created and makes two databases,
ordersandshipping:sqlCREATE DATABASE orders; CREATE DATABASE shipping;Start everything:
bashdocker compose up -d --wait dotnet run --project src/Orders.Api
Check it works
dotnet build OutboxInbox.slnx -warnaserrorYou should see 0 Warning(s) and 0 Error(s).
curl -i http://localhost:5080/HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{"service":"Orders.Api"}Check that both databases exist:
docker compose exec postgres psql -U postgres -tAc "select datname from pg_database where datname in ('orders','shipping')"orders
shippingOpen the RabbitMQ management UI at http://localhost:15672 and sign in with guest / guest. These are the image's local defaults; never use them on a server.
Stop the API with Ctrl+C. Leave the containers running for the next step, or stop them with docker compose down (add -v to delete the data too).
Why it works
Two services, two databases. The guide builds an Orders API and, later, a Shipping worker. Each one owns its data. Running both databases in one PostgreSQL container keeps the laptop light, but the apps never share tables. That rule matters later: the only way Shipping learns about an order is through a message.
Port 5433. Inside the container PostgreSQL listens on its usual port 5432. Compose publishes it on port 5433 of your machine, because many developers already run a local PostgreSQL on 5432, and the apps would silently connect to the wrong server (you would see role "postgres" does not exist).
Pinned tags and health checks. postgres:17.12-alpine and rabbitmq:4.4.1-management name an exact patch, so the guide works the same next year. A health check is a command Docker runs inside the container to decide when it is ready. docker compose up --wait blocks until both report healthy, so the app never starts against a database that is still booting.
RabbitMQ is a message broker: a server that accepts messages from one program and hands them to others. The -management image adds the web UI on port 15672, which you will use to watch messages move.
Typed results. TypedResults.Ok(...) returns a strongly typed Ok<T> instead of a plain object. The compiler and OpenAPI tools can see exactly what each endpoint returns.