Files
Claude def73fa1c4 Add spring-boot-microservices-project: config server, Eureka, gateway and three services on Boot 4.1.1 + Spring Cloud 2025.1.3
Product, order and inventory services behind Spring Cloud Gateway (WebMVC), configuration from a Config Server,
discovery with Eureka, a Resilience4j circuit breaker on order -> inventory and Brave tracing. Run as six plain jars;
output/ holds real transcripts (config, registry, requests, trace propagation, circuit breaker, startup race and the
load-balanced RestClient.Builder trap). Dockerfile and docker-compose.yml are included but were not run.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HhW8LD8r3EigoBaCGrQZx5
2026-10-21 17:08:42 +00:00

71 lines
2.9 KiB
Plaintext

# order-service -> inventory-service behind a Resilience4j circuit breaker (4-call window, 50% threshold, 5 s open)
--- healthy: circuit state, then one order ---
$ curl -X GET localhost:8080/api/orders/circuit
HTTP 200
{"state":"CLOSED","failedCalls":0,"notPermittedCalls":0}
$ curl -X POST localhost:8080/api/orders -d '{"productId":1,"quantity":1}'
HTTP 201
{"id":3,"productId":1,"productName":"Mechanical keyboard","quantity":1,"total":89.90,"currency":"EUR","status":"CONFIRMED"}
--- switch inventory-service to failing (POST /inventory/chaos?down=true), then place 4 orders ---
$ curl -X POST localhost:8080/api/inventory/chaos?down=true
HTTP 200
{"down":true}
$ curl -X POST localhost:8080/api/orders -d '{"productId":1,"quantity":1}'
HTTP 201
{"id":4,"productId":1,"productName":"Mechanical keyboard","quantity":1,"total":89.90,"currency":"EUR","status":"PENDING_INVENTORY"}
$ curl -X POST localhost:8080/api/orders -d '{"productId":1,"quantity":1}'
HTTP 201
{"id":5,"productId":1,"productName":"Mechanical keyboard","quantity":1,"total":89.90,"currency":"EUR","status":"PENDING_INVENTORY"}
$ curl -X POST localhost:8080/api/orders -d '{"productId":1,"quantity":1}'
HTTP 201
{"id":6,"productId":1,"productName":"Mechanical keyboard","quantity":1,"total":89.90,"currency":"EUR","status":"PENDING_INVENTORY"}
$ curl -X POST localhost:8080/api/orders -d '{"productId":1,"quantity":1}'
HTTP 201
{"id":7,"productId":1,"productName":"Mechanical keyboard","quantity":1,"total":89.90,"currency":"EUR","status":"PENDING_INVENTORY"}
$ curl -X GET localhost:8080/api/orders/circuit
HTTP 200
{"state":"OPEN","failedCalls":2,"notPermittedCalls":2}
--- circuit is OPEN: 2 more orders. inventory reserve calls before and after prove the calls were not even attempted ---
$ curl -X GET localhost:8080/api/inventory/stats
HTTP 200
{"reserveCalls":8}
$ curl -X POST localhost:8080/api/orders -d '{"productId":1,"quantity":1}'
HTTP 201
{"id":8,"productId":1,"productName":"Mechanical keyboard","quantity":1,"total":89.90,"currency":"EUR","status":"PENDING_INVENTORY"}
$ curl -X POST localhost:8080/api/orders -d '{"productId":1,"quantity":1}'
HTTP 201
{"id":9,"productId":1,"productName":"Mechanical keyboard","quantity":1,"total":89.90,"currency":"EUR","status":"PENDING_INVENTORY"}
$ curl -X GET localhost:8080/api/inventory/stats
HTTP 200
{"reserveCalls":8}
$ curl -X GET localhost:8080/api/orders/circuit
HTTP 200
{"state":"OPEN","failedCalls":2,"notPermittedCalls":4}
--- inventory-service recovers; wait 6 seconds (> the 5 s open window), then order again ---
$ curl -X POST localhost:8080/api/inventory/chaos?down=false
HTTP 200
{"down":false}
$ curl -X POST localhost:8080/api/orders -d '{"productId":1,"quantity":1}'
HTTP 201
{"id":10,"productId":1,"productName":"Mechanical keyboard","quantity":1,"total":89.90,"currency":"EUR","status":"CONFIRMED"}
$ curl -X GET localhost:8080/api/orders/circuit
HTTP 200
{"state":"CLOSED","failedCalls":0,"notPermittedCalls":0}