Skip to content

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
AddressWhat
http://localhost:5080Orders.Api
http://localhost:15672RabbitMQ management UI (guest / guest, local only)
http://localhost:18888Aspire 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 ​

#FeatureDo thisExpect
1API answerscurl localhost:5080/{"service":"Orders.Api"}
2Place an ordercurl -i -X POST localhost:5080/orders -H 'content-type: application/json' -d "$ORDER"201 Created with a Location header
3Read it backcurl -i <Location>200 with the same order
4Unknown ordercurl -i localhost:5080/orders/0193a000-0000-7000-8000-000000000000404, application/problem+json
5ValidationPOST with "customerEmail":"not-an-email" and "quantity":0400 with an errors entry per field
6Outbox row in the same transactiondocker 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
7Published with confirmsAPI logPublished outbox message <id> (orders.order-placed.v1)
8ConsumedWorker logReceived order ... then Created shipment for order ...
9Inbox and shipmentdocker 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
10Duplicate skippedClear 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
11Outbox backoffStop the worker, docker compose exec rabbitmq rabbitmqctl delete_queue shipping.order-placed, place an orderAPI logs attempt 1, 2, 3 … with growing waits; attempts, next_attempt_at, last_error filled. Start the worker: the next try succeeds
12Poison messagePublish not json (see step 07)Worker logs Dead-lettered unreadable message; 1 message in shipping.order-placed.dlq with x-death reason rejected
13Delivery limitdocker 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
14Two publishersStart 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
15One trace across servicesOpen http://localhost:18888/traces after placing an orderOne POST /orders/ trace with spans from Orders.Api and Shipping.Worker
16Livenesscurl -i localhost:5080/health/live200 Healthy
17Readinesscurl localhost:5080/health/readyHealthy JSON with postgresql, rabbitmq, outbox
18Broker outagedocker compose stop rabbitmq, place an order, wait 30 s, call readinessOrder still 201; readiness 503 (rabbitmq Unhealthy) and outbox Degraded with the lag. docker compose start rabbitmq: everything recovers by itself
19CleanupRestart the API with dotnet run --project src/Orders.Api -- --Outbox:Retention=00:00:30 --Outbox:CleanupInterval=00:00:05Log 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 queues

What 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.

MIT licensed. Every step is a commit: git checkout step-01.