# 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}