Prev Next

Spring / Resilience4j Interview questions

Why does Resilience4j rely on functional interfaces like Supplier and Function?

Building around Supplier, Function, Runnable, Callable, and CompletionStage means Resilience4j can decorate any piece of existing code that already fits one of those shapes, without requiring it to extend a base class or implement a library-specific command interface the way Hystrix's HystrixCommand did.

It also makes composition trivial: because a decorated call is still just a Supplier (or whichever type it started as), it can be passed to another decorator, stored, tested, or composed with standard Java functional idioms like Function.andThen - there's no special "decorated" type with its own rules to learn.

This design also keeps the library framework-agnostic - the same core decorators work in a plain Java application, a Spring Boot service, or a reactive pipeline, since none of them depend on inheriting from Resilience4j-specific base types.

Building on plain functional interfaces means Resilience4j can:
Because a decorated call remains a plain Supplier, it can be:

More Related questions...

What is Resilience4j? What are the core modules of Resilience4j? What is a Circuit Breaker in Resilience4j? What are the states of a CircuitBreaker? What is the Retry module used for? What is a RateLimiter in Resilience4j? What is the Bulkhead pattern in Resilience4j? What is a TimeLimiter in Resilience4j? What is the Cache module in Resilience4j? How do you add Resilience4j to a Spring Boot project? What is the purpose of the Decorators class? Define fallback method in Resilience4j? What are the types of Bulkhead implementations? List the key configuration properties of a CircuitBreaker? How do you apply @CircuitBreaker in a Spring Boot service? Why is Resilience4j often preferred over Hystrix? How does the sliding window work in CircuitBreaker? What is the difference between COUNT_BASED and TIME_BASED sliding windows? How is failure rate calculated in a CircuitBreaker? What is the difference between CircuitBreaker and Bulkhead? How does the half-open state behave in a CircuitBreaker? Why do we use recordExceptions versus ignoreExceptions? When should you use RateLimiter instead of Bulkhead? What happens when a CircuitBreaker transitions to OPEN? How is Resilience4j's Retry different from a plain retry loop? Explain the execution flow of a call decorated with CircuitBreaker, Retry, and Bulkhead together? How do you combine multiple Resilience4j decorators using the Decorators class? Which is better and why: SemaphoreBulkhead or ThreadPoolBulkhead? How can you optimize CircuitBreaker configuration for a high-throughput service? How do you troubleshoot a CircuitBreaker that never opens despite failures? Explain the lifecycle of a CircuitBreaker instance? What is the difference between TimeLimiter and a plain timeout? How does RegistryEventConsumer work in Resilience4j? Why does Resilience4j rely on functional interfaces like Supplier and Function? How do you monitor Resilience4j metrics with Micrometer? What is the difference between waitDurationInOpenState and permittedNumberOfCallsInHalfOpenState? How do you write a unit test for a CircuitBreaker-protected method? Explain the internal working of exponential backoff in the Retry module? What is the difference between CallNotPermittedException and other Resilience4j exceptions? How do you use event publishers to log CircuitBreaker state transitions? When would you choose a RateLimiter over a Bulkhead for protecting a downstream call? How does Resilience4j integrate with reactive streams in WebFlux? What is the difference between recordException and recordResult predicates? Explain the internal working of automaticTransitionFromOpenToHalfOpenEnabled? How do you configure Resilience4j using application.yml in Spring Boot? What is the difference between the Resilience4j Cache module and a plain in-memory cache like Guava? How can you optimize retry strategies to avoid retry storms? Explain the execution flow when a fallback method itself throws an exception? How do you troubleshoot memory growth caused by an unbounded ThreadPoolBulkhead queue? Explain how Resilience4j's modular design influences microservice resilience architecture at scale?
Show more question and Answers...


Comments & Discussions