Testing locally
A checklist to exercise every feature of the finished guide (step-10) on your machine. Each line says what to do and what you should see. Run the commands from the repository root.
Start everything
bash
docker compose up -d --wait # postgres (host port 5433), rabbitmq, aspire-dashboard
dotnet tool restore # dotnet-ef, only needed to add migrations
dotnet build OutboxInbox.slnx -warnaserror
dotnet run --project src/Shipping.Worker # terminal 1
dotnet run --project src/Orders.Api # terminal 2| Address | What |
|---|---|
| http://localhost:5080 | Orders.Api |
| http://localhost:15672 | RabbitMQ management UI (guest / guest, local only) |
| http://localhost:18888 | Aspire dashboard (traces and logs) |
A shell variable keeps the order commands short:
bash
ORDER='{"customerEmail":"alex@contoso.com","items":[{"sku":"BOOK-1","quantity":2}]}'Checklist
| # | Feature | Do this | Expect |
|---|---|---|---|
| 1 | API answers | curl localhost:5080/ | {"service":"Orders.Api"} |
| 2 | Place an order | curl -i -X POST localhost:5080/orders -H 'content-type: application/json' -d "$ORDER" | 201 Created with a Location header |
| 3 | Read it back | curl -i <Location> | 200 with the same order |
| 4 | Unknown order | curl -i localhost:5080/orders/0193a000-0000-7000-8000-000000000000 | 404, application/problem+json |
| 5 | Validation | POST with "customerEmail":"not-an-email" and "quantity":0 | 400 with an errors entry per field |
| 6 | Outbox row in the same transaction | docker compose exec postgres psql -U postgres -d orders -c "select id, type, processed_at, trace_parent from outbox_messages order by occurred_at desc limit 1" | One row per order; processed_at set within a second |
| 7 | Published with confirms | API log | Published outbox message <id> (orders.order-placed.v1) |
| 8 | Consumed | Worker log | Received order ... then Created shipment for order ... |
| 9 | Inbox and shipment | docker compose exec postgres psql -U postgres -d shipping -c "select count(*) from inbox_messages" -c "select count(*) from shipments" | Both counts grow by one per order |
| 10 | Duplicate skipped | Clear processed_at of the newest outbox row: docker compose exec postgres psql -U postgres -d orders -c "update outbox_messages set processed_at = null where id = (select id from outbox_messages order by occurred_at desc limit 1)" | Worker logs Skipped duplicate message ...; shipment count unchanged |
| 11 | Outbox backoff | Stop the worker, docker compose exec rabbitmq rabbitmqctl delete_queue shipping.order-placed, place an order | API logs attempt 1, 2, 3 … with growing waits; attempts, next_attempt_at, last_error filled. Start the worker: the next try succeeds |
| 12 | Poison message | Publish not json (see step 07) | Worker logs Dead-lettered unreadable message; 1 message in shipping.order-placed.dlq with x-death reason rejected |
| 13 | Delivery limit | docker compose stop postgres, publish a valid message by hand (step 07) | 6 attempts 1 s apart, then dead-lettered with reason delivery_limit. Then docker compose up -d --wait postgres |
| 14 | Two publishers | Start a second API with dotnet run --project src/Orders.Api --launch-profile http-2, send 300 orders with curl --parallel (see step 08) | Both instances log Published; their counts add up to 300; no Skipped duplicate in the worker |
| 15 | One trace across services | Open http://localhost:18888/traces after placing an order | One POST /orders/ trace with spans from Orders.Api and Shipping.Worker |
| 16 | Liveness | curl -i localhost:5080/health/live | 200 Healthy |
| 17 | Readiness | curl localhost:5080/health/ready | Healthy JSON with postgresql, rabbitmq, outbox |
| 18 | Broker outage | docker compose stop rabbitmq, place an order, wait 30 s, call readiness | Order still 201; readiness 503 (rabbitmq Unhealthy) and outbox Degraded with the lag. docker compose start rabbitmq: everything recovers by itself |
| 19 | Cleanup | Restart the API with dotnet run --project src/Orders.Api -- --Outbox:Retention=00:00:30 --Outbox:CleanupInterval=00:00:05 | Log Deleted N processed outbox messages older than ... |
Clean up
Stop the apps with Ctrl+C, then:
bash
docker compose down # keeps the data volumes
docker compose down -v # also deletes the databases and queuesWhat this does not test
Everything here runs on one machine with one RabbitMQ node. It does not test a RabbitMQ cluster, network partitions, or a managed broker. The pattern itself is broker-independent; on Azure Service Bus, for example, the publisher and inbox stay the same, while the broker side differs: Service Bus has built-in duplicate detection (by message id, within a time window), sessions for ordered processing, and a dead-letter queue on every queue. Those differences are not tested in this guide.