Spring / Resilience4j Interview questions
How is Resilience4j's Retry different from a plain retry loop?
A hand-rolled retry loop usually just wraps a call in a for-loop with a try/catch and a fixed sleep, which works but scatters retry logic across the codebase and makes it hard to reason about consistently.
Resilience4j's Retry centralizes that behavior in a named, reusable Retry instance with configurable maxAttempts, a pluggable IntervalFunction for backoff strategy (fixed, exponential, or exponential with jitter), and predicates like retryOnException or retryOnResult so retries can target specific failure conditions instead of blindly retrying anything that throws.
It also exposes an event publisher that fires on every retry attempt and on final success/failure, which a plain loop doesn't give you for free, and it composes cleanly with other decorators like CircuitBreaker through the Decorators API rather than needing custom glue code.
More Related questions...