Spring / Resilience4j Interview questions
Define fallback method in Resilience4j?
A fallback is an alternate code path that runs when the primary, resilience-wrapped call fails or is rejected, so the caller gets a usable result instead of a raw exception.
With the functional API this is done via Try.of(supplier).recover(throwable -> fallbackValue) or Decorators...withFallback(predicate, handler); with Spring annotations, it's a method with the same return type and an extra Throwable parameter, referenced by name in @CircuitBreaker(fallbackMethod = "fallback").
Good fallbacks return something genuinely safe to use - a cached value, a default, or a degraded response - rather than silently swallowing the failure and returning something misleading.
More Related questions...