Spring / Resilience4j Interview questions
Explain the execution flow of a call decorated with CircuitBreaker, Retry, and Bulkhead together?
When these three are composed, the order they're applied in determines which one "sees" the call first, and getting that order wrong changes the actual behavior even though the code looks similar either way.
The generally recommended order is Bulkhead (outermost) → CircuitBreaker → Retry (innermost): the Bulkhead first decides whether there's even capacity to attempt the call; if there is, the CircuitBreaker checks whether it's CLOSED or HALF_OPEN enough to permit an attempt; only then does Retry actually execute the call and, on failure, loop back to try again.
sequenceDiagram participant Caller participant Bulkhead participant CircuitBreaker participant Retry participant Service Caller->>Bulkhead: request permit Bulkhead->>CircuitBreaker: permit granted CircuitBreaker->>Retry: call permitted Retry->>Service: attempt 1 Service-->>Retry: failure Retry->>Service: attempt 2 Service-->>Retry: success Retry-->>CircuitBreaker: result recorded CircuitBreaker-->>Caller: return result
Placing Retry innermost matters specifically: it means each full retry sequence - all attempts combined - is recorded as a single outcome against the CircuitBreaker, rather than every individual retry attempt counting separately and prematurely tripping the breaker open from what's really just one logical call.
More Related questions...