HomeGuidesChangelog
GuidesGitHubLog In
Guides

Examples

Examples of resilience4j-retry

Create a RetryRegistry

Create a RetryRegistry with a custom RetryConfig.

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