Resilience4j is a fault tolerance library for Java™

Resilience4j is a lightweight fault tolerance library inspired by Netflix Hystrix, but designed for functional programming.
Resilience4j provides higher-order functions (decorators) to enhance any functional interface, lambda expression or method reference with a Circuit Breaker, Rate Limiter, Retry or Bulkhead. You can stack more than one decorator on any functional interface, lambda expression or method reference. The advantage is that you have the choice to select the decorators you need and nothing else.

Supplier<String> supplier = () -> service.sayHelloWorld(param1);

String result = Decorators.ofSupplier(supplier)
  .withFallback(asList(CallNotPermittedException.class, BulkheadFullException.class),  
      throwable -> "Hello from fallback")

With Resilience4j you don’t have to go all-in, you can pick what you need.

Get Started


Examples of resilience4j-retry

Create a RetryRegistry

Create a RetryRegistry with a custom RetryConfig.

RetryConfig config = RetryConfig.custom()
    .retryOnResult(response -> response.getStatus() == 500)
    .retryOnException(e -> e instanceof WebServiceException)
    .retryExceptions(IOException.class, TimeoutException.class)
    .ignoreExceptions(BunsinessException.class, OtherBunsinessException.class)
// Create a RetryRegistry with a custom global configuration
RetryRegistry registry = RetryRegistry.of(config);


Examples of resilience4j-retry

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.