kandi background
Explore Kits

resilience4j | fault tolerance library designed | HTTP library

 by   resilience4j Java Version: v1.7.1 License: Apache-2.0

 by   resilience4j Java Version: v1.7.1 License: Apache-2.0

Download this library from

kandi X-RAY | resilience4j Summary

resilience4j is a Java library typically used in Networking, HTTP applications. resilience4j has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can download it from GitHub, Maven.
Resilience4j provides several core modules:. There are also add-on modules for metrics, Retrofit, Feign, Kotlin, Spring, Ratpack, Vertx, RxJava2 and more.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • resilience4j has a highly active ecosystem.
  • It has 7892 star(s) with 1060 fork(s). There are 223 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 146 open issues and 791 have been closed. On average issues are closed in 71 days. There are 14 open pull requests and 0 closed requests.
  • It has a positive sentiment in the developer community.
  • The latest version of resilience4j is v1.7.1
resilience4j Support
Best in #HTTP
Average in #HTTP
resilience4j Support
Best in #HTTP
Average in #HTTP

quality kandi Quality

  • resilience4j has 0 bugs and 0 code smells.
resilience4j Quality
Best in #HTTP
Average in #HTTP
resilience4j Quality
Best in #HTTP
Average in #HTTP

securitySecurity

  • resilience4j has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • resilience4j code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
resilience4j Security
Best in #HTTP
Average in #HTTP
resilience4j Security
Best in #HTTP
Average in #HTTP

license License

  • resilience4j is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
resilience4j License
Best in #HTTP
Average in #HTTP
resilience4j License
Best in #HTTP
Average in #HTTP

buildReuse

  • resilience4j releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • resilience4j saves you 51019 person hours of effort in developing the same functionality from scratch.
  • It has 63844 lines of code, 6105 functions and 971 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
resilience4j Reuse
Best in #HTTP
Average in #HTTP
resilience4j Reuse
Best in #HTTP
Average in #HTTP
Top functions reviewed by kandi - BETA

kandi has reviewed resilience4j and discovered the below as its top functions. This is intended to give you an instant insight into resilience4j implemented functionality, and help decide if they suit your requirements.

  • Configures the interceptor .
  • Deploys timelimiter events .
  • Builds CircuitBreaker config .
  • Collect gauge samples from circuit breaker names .
  • Registers meter metrics .
  • Intercepts bulkhead annotation .
  • Converts a given event to a CircuitBreakerEventDTO .
  • Publish metrics .
  • Returns a CompletionStage that wraps the provided Supplier .
  • Attempts to fallback for the given method invocation context .

resilience4j Key Features

resilience4j-circuitbreaker: Circuit breaking

resilience4j-ratelimiter: Rate limiting

resilience4j-bulkhead: Bulkheading

resilience4j-retry: Automatic retrying (sync and async)

resilience4j-timelimiter: Timeout handling

resilience4j-cache: Result caching

1. Introduction

copy iconCopydownload iconDownload
// Create a CircuitBreaker with default configuration
CircuitBreaker circuitBreaker = CircuitBreaker.ofDefaults("backendService");

// Create a Retry with default configuration
// 3 retry attempts and a fixed time interval between retries of 500ms
Retry retry = Retry.ofDefaults("backendService");

// Create a Bulkhead with default configuration
Bulkhead bulkhead = Bulkhead.ofDefaults("backendService");

Supplier<String> supplier = () -> backendService
  .doSomething(param1, param2);

// Decorate your call to backendService.doSomething()
// with a Bulkhead, CircuitBreaker and Retry
// **note: you will need the resilience4j-all dependency for this
Supplier<String> decoratedSupplier = Decorators.ofSupplier(supplier)
  .withCircuitBreaker(circuitBreaker)
  .withBulkhead(bulkhead)
  .withRetry(retry)
  .decorate();

// Execute the decorated supplier and recover from any exception
String result = Try.ofSupplier(decoratedSupplier)
  .recover(throwable -> "Hello from Recovery").get();

// When you don't want to decorate your lambda expression,
// but just execute it and protect the call by a CircuitBreaker.
String result = circuitBreaker
  .executeSupplier(backendService::doSomething);

// You can also run the supplier asynchronously in a ThreadPoolBulkhead
 ThreadPoolBulkhead threadPoolBulkhead = ThreadPoolBulkhead
  .ofDefaults("backendService");

// The Scheduler is needed to schedule a timeout on a non-blocking CompletableFuture
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(3);
TimeLimiter timeLimiter = TimeLimiter.of(Duration.ofSeconds(1));

CompletableFuture<String> future = Decorators.ofSupplier(supplier)
    .withThreadPoolBulkhead(threadPoolBulkhead)
    .withTimeLimiter(timeLimiter, scheduler)
    .withCircuitBreaker(circuitBreaker)
    .withFallback(asList(TimeoutException.class, CallNotPermittedException.class, BulkheadFullException.class),
      throwable -> "Hello from Recovery")
    .get().toCompletableFuture();

6.1. CircuitBreaker, Retry and Fallback

copy iconCopydownload iconDownload
// Simulates a Backend Service
public interface BackendService {
    String doSomething();
}

// Create a CircuitBreaker (use default configuration)
CircuitBreaker circuitBreaker = CircuitBreaker.ofDefaults("backendName");
// Create a Retry with at most 3 retries and a fixed time interval between retries of 500ms
Retry retry = Retry.ofDefaults("backendName");

// Decorate your call to BackendService.doSomething() with a CircuitBreaker
Supplier<String> decoratedSupplier = CircuitBreaker
    .decorateSupplier(circuitBreaker, backendService::doSomething);

// Decorate your call with automatic retry
decoratedSupplier = Retry
    .decorateSupplier(retry, decoratedSupplier);

// Execute the decorated supplier and recover from any exception
String result = Try.ofSupplier(decoratedSupplier)
    .recover(throwable -> "Hello from Recovery").get();

// When you don't want to decorate your lambda expression,
// but just execute it and protect the call by a CircuitBreaker.
String result = circuitBreaker.executeSupplier(backendService::doSomething);

6.2. RateLimiter

copy iconCopydownload iconDownload
// Create a custom RateLimiter configuration
RateLimiterConfig config = RateLimiterConfig.custom()
    .timeoutDuration(Duration.ofMillis(100))
    .limitRefreshPeriod(Duration.ofSeconds(1))
    .limitForPeriod(1)
    .build();
// Create a RateLimiter
RateLimiter rateLimiter = RateLimiter.of("backendName", config);

// Decorate your call to BackendService.doSomething()
Supplier<String> restrictedSupplier = RateLimiter
    .decorateSupplier(rateLimiter, backendService::doSomething);

// First call is successful
Try<String> firstTry = Try.ofSupplier(restrictedSupplier);
assertThat(firstTry.isSuccess()).isTrue();

// Second call fails, because the call was not permitted
Try<String> secondTry = Try.of(restrictedSupplier);
assertThat(secondTry.isFailure()).isTrue();
assertThat(secondTry.getCause()).isInstanceOf(RequestNotPermitted.class);

6.3. Bulkhead

copy iconCopydownload iconDownload
// Create a custom Bulkhead configuration
BulkheadConfig config = BulkheadConfig.custom()
    .maxConcurrentCalls(150)
    .maxWaitDuration(100)
    .build();

Bulkhead bulkhead = Bulkhead.of("backendName", config);

Supplier<String> supplier = Bulkhead
    .decorateSupplier(bulkhead, backendService::doSomething);

7.1. Examples

copy iconCopydownload iconDownload
circuitBreaker.getEventPublisher()
    .onSuccess(event -> logger.info(...))
    .onError(event -> logger.info(...))
    .onIgnoredError(event -> logger.info(...))
    .onReset(event -> logger.info(...))
    .onStateTransition(event -> logger.info(...));
// Or if you want to register a consumer listening to all events, you can do:
circuitBreaker.getEventPublisher()
    .onEvent(event -> logger.info(...));

10. License

copy iconCopydownload iconDownload
http://www.apache.org/licenses/LICENSE-2.0

Resiliency4j circuit breaker with retry configuration not working

copy iconCopydownload iconDownload
Retry( CircuitBreaker( RateLimiter( TimeLimiter( Bulkhead( function)))))
resilience4j:
  circuitbreaker:
    circuitBreakerAspectOrder: 1
  retry:
    retryAspectOrder: 2
-----------------------
Retry( CircuitBreaker( RateLimiter( TimeLimiter( Bulkhead( function)))))
resilience4j:
  circuitbreaker:
    circuitBreakerAspectOrder: 1
  retry:
    retryAspectOrder: 2

How to run the SpringBootTest with only a single bean and with included resilience4j annotations

copy iconCopydownload iconDownload
@Bulkhead(name = "fooBulkhead", type = Type.THREADPOOL)
@CircuitBreaker(
        name = "fooCircuitBreaker",
        fallbackMethod = "fooFallback"
)
@TimeLimiter(
        name = "fooTimeLimiter"
)
public CompletableFuture<FooResponse> foo() {
    //...
}
@SpringBootTest(classes = FooService.class)
@EnableAspectJAutoProxy
@Import(value = {CircuitBreakerAutoConfiguration.class, TimeLimiterAutoConfiguration.class, BulkheadAutoConfiguration.class})
public class FooServiceIT {
    //...
}
-----------------------
@Bulkhead(name = "fooBulkhead", type = Type.THREADPOOL)
@CircuitBreaker(
        name = "fooCircuitBreaker",
        fallbackMethod = "fooFallback"
)
@TimeLimiter(
        name = "fooTimeLimiter"
)
public CompletableFuture<FooResponse> foo() {
    //...
}
@SpringBootTest(classes = FooService.class)
@EnableAspectJAutoProxy
@Import(value = {CircuitBreakerAutoConfiguration.class, TimeLimiterAutoConfiguration.class, BulkheadAutoConfiguration.class})
public class FooServiceIT {
    //...
}

Autogenerated OAuth2 login page for AWS Cognito in reactive Spring Boot application fails

copy iconCopydownload iconDownload
spring:
  security:
    oauth2:
      client:
        registration:
          cognito:
            client-id: XXX
            client-secret: XXX
            scope: openid
            redirect-uri: http://localhost:8080/login/oauth2/code/cognito
            clientName: fitnesstest
        provider:
          cognito:
            issuerUri: https://cognito-idp.eu-central-1.amazonaws.com/eu-central-1_XXX

resilience4j-retry:1.7.1 - does not retry websocket connection

copy iconCopydownload iconDownload
     @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        RetryConfig config = RetryConfig.custom()
                .maxAttempts(5)
                .waitDuration(Duration.ofSeconds(5))
                .build();

        RetryRegistry registry = RetryRegistry.of(config);
        Retry retry = registry.retry("retryableSupplier", config);
        CheckedFunction0<String> checkedSupplier = Retry.decorateCheckedSupplier(retry, connector::startConnection);

        Retry.EventPublisher publisher = retry.getEventPublisher();
        publisher.onRetry(event1 -> System.out.println("Retrying: " + event1.toString()));
        publisher.onSuccess(event2 -> System.out.println("Retrying Success: " +event2.toString()));

        Try<String> result = Try.of(checkedSupplier).recover((throwable -> "I am recovered"));
        System.out.println("result: " + result);
    }

Can't get Resilience4j @RateLimiter to work with Spring Boot

copy iconCopydownload iconDownload
public interface Backend {
   void callBackendA();
}

@Component // this is a spring bean!
@Log4j2
public class LoggingBackendImpl implements Backend {
   @RateLimiter(name = "backendA")
   public void callBackendA() {
      log.info("calling backend");
   }
}


@Component
class Resilience4jDemo implements CommandLineRunner {
    @Autowired
    Backend backend;  // this has to be managed by spring 

    @Override
    public void run(String... args) throws Exception {
        for (int i = 0; i < 100; i++) {
            backend.callBackendA();
        }
    }
}

Error 302 Using FeignClient in Spring Boot Microservices

copy iconCopydownload iconDownload
@GetMapping("/users/usuarioExisteDatos")
public ResponseEntity<?> preguntarUsuarioExiste(@RequestParam(value = "username") String username, @RequestParam(value = "email") String email, @RequestParam(value = "cellPhone") String cellPhone) throws InterruptedException {
    boolean exists = uRepository.existsByUsernameOrEmailOrCellPhone(username, email, cellPhone);
    if (exists) {
        return ResponseEntity.ok().build();
    } else {
        return ResponseEntity.notFound().build();
    }
}
{
  "exists": false
}
-----------------------
@GetMapping("/users/usuarioExisteDatos")
public ResponseEntity<?> preguntarUsuarioExiste(@RequestParam(value = "username") String username, @RequestParam(value = "email") String email, @RequestParam(value = "cellPhone") String cellPhone) throws InterruptedException {
    boolean exists = uRepository.existsByUsernameOrEmailOrCellPhone(username, email, cellPhone);
    if (exists) {
        return ResponseEntity.ok().build();
    } else {
        return ResponseEntity.notFound().build();
    }
}
{
  "exists": false
}

jhipster microservices client springcloud config with authorization header to jhipster registry

copy iconCopydownload iconDownload
jhipster:
  xxxxxxxxx
  registry:
    password: xxxxxxxxxxxxx
jhipster:
  registry:
    password: <correct_password>
        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝

:: JHipster 🤓  :: Running Spring Boot 2.5.4 ::
:: https://www.jhipster.tech ::

2021-11-08 11:36:28.507  INFO 3872 --- [           main] com.okta.developer.store.StoreApp        : No active profile set, falling back to default profiles: dev,api-docs
2021-11-08 11:36:29.639 DEBUG 3872 --- [           main] i.g.r.utils.RxJava2OnClasspathCondition  : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
2021-11-08 11:36:29.641 DEBUG 3872 --- [           main] i.g.r.utils.ReactorOnClasspathCondition  : Reactor related Aspect extensions are not activated because Resilience4j Reactor module is not on the classpath.
2021-11-08 11:36:29.656 DEBUG 3872 --- [           main] i.g.r.utils.RxJava2OnClasspathCondition  : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
-----------------------
jhipster:
  xxxxxxxxx
  registry:
    password: xxxxxxxxxxxxx
jhipster:
  registry:
    password: <correct_password>
        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝

:: JHipster 🤓  :: Running Spring Boot 2.5.4 ::
:: https://www.jhipster.tech ::

2021-11-08 11:36:28.507  INFO 3872 --- [           main] com.okta.developer.store.StoreApp        : No active profile set, falling back to default profiles: dev,api-docs
2021-11-08 11:36:29.639 DEBUG 3872 --- [           main] i.g.r.utils.RxJava2OnClasspathCondition  : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
2021-11-08 11:36:29.641 DEBUG 3872 --- [           main] i.g.r.utils.ReactorOnClasspathCondition  : Reactor related Aspect extensions are not activated because Resilience4j Reactor module is not on the classpath.
2021-11-08 11:36:29.656 DEBUG 3872 --- [           main] i.g.r.utils.RxJava2OnClasspathCondition  : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
-----------------------
jhipster:
  xxxxxxxxx
  registry:
    password: xxxxxxxxxxxxx
jhipster:
  registry:
    password: <correct_password>
        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝

:: JHipster 🤓  :: Running Spring Boot 2.5.4 ::
:: https://www.jhipster.tech ::

2021-11-08 11:36:28.507  INFO 3872 --- [           main] com.okta.developer.store.StoreApp        : No active profile set, falling back to default profiles: dev,api-docs
2021-11-08 11:36:29.639 DEBUG 3872 --- [           main] i.g.r.utils.RxJava2OnClasspathCondition  : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
2021-11-08 11:36:29.641 DEBUG 3872 --- [           main] i.g.r.utils.ReactorOnClasspathCondition  : Reactor related Aspect extensions are not activated because Resilience4j Reactor module is not on the classpath.
2021-11-08 11:36:29.656 DEBUG 3872 --- [           main] i.g.r.utils.RxJava2OnClasspathCondition  : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.

Resilience4J for Springboot - what is the use of registerHealthIndicator: true

copy iconCopydownload iconDownload
management.endpoint.health.show-details = always

What is the expected behavior of Resilience4J Retry?

copy iconCopydownload iconDownload
package com.resilience.retry.config;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import io.github.resilience4j.retry.RetryRegistry;
import lombok.extern.slf4j.Slf4j;

@Component
@Slf4j
public class RetryRegistryEventListener {

    @Autowired
    private RetryRegistry registry;


    @PostConstruct
    public void postConstruct() {
        //registry.retry(<resilience retry instance name>)
        registry.retry("sample-api").getEventPublisher()
                .onRetry(ev -> log.info("#### RetryRegistryEventListener message: {}", ev));
    }
}
2021-11-01 14:55:12.337  INFO 18176 --- [nio-8080-exec-1] c.r.retry.controller.RetryController     : Sample Api call receieved
2021-11-01 14:55:12.345  INFO 18176 --- [nio-8080-exec-1] c.r.r.config.RetryRegistryEventListener  : #### RetryRegistryEventListener message: 2021-11-01T14:55:12.344325600+05:30[Asia/Calcutta]: Retry 'sample-api', waiting PT10S until attempt '1'. Last attempt failed with exception 'org.springframework.web.client.HttpServerErrorException: 500 INTERNAL_SERVER_ERROR'.
2021-11-01 14:55:12.350  INFO 18176 --- [nio-8080-exec-1] c.r.retry.controller.RetryController     : messsage: 2021-11-01T14:55:12.344325600+05:30[Asia/Calcutta]: Retry 'sample-api', waiting PT10S until attempt '1'. Last attempt failed with exception 'org.springframework.web.client.HttpServerErrorException: 500 INTERNAL_SERVER_ERROR'.
2021-11-01 14:55:22.359  INFO 18176 --- [nio-8080-exec-1] c.r.retry.controller.RetryController     : Sample Api call receieved
2021-11-01 14:55:22.360  INFO 18176 --- [nio-8080-exec-1] c.r.r.config.RetryRegistryEventListener  : #### RetryRegistryEventListener message: 2021-11-01T14:55:22.360672900+05:30[Asia/Calcutta]: Retry 'sample-api', waiting PT10S until attempt '2'. Last attempt failed with exception 'org.springframework.web.client.HttpServerErrorException: 500 INTERNAL_SERVER_ERROR'.
2021-11-01 14:55:22.361  INFO 18176 --- [nio-8080-exec-1] c.r.retry.controller.RetryController     : messsage: 2021-11-01T14:55:22.360672900+05:30[Asia/Calcutta]: Retry 'sample-api', waiting PT10S until attempt '2'. Last attempt failed with exception 'org.springframework.web.client.HttpServerErrorException: 500 INTERNAL_SERVER_ERROR'.
-----------------------
package com.resilience.retry.config;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import io.github.resilience4j.retry.RetryRegistry;
import lombok.extern.slf4j.Slf4j;

@Component
@Slf4j
public class RetryRegistryEventListener {

    @Autowired
    private RetryRegistry registry;


    @PostConstruct
    public void postConstruct() {
        //registry.retry(<resilience retry instance name>)
        registry.retry("sample-api").getEventPublisher()
                .onRetry(ev -> log.info("#### RetryRegistryEventListener message: {}", ev));
    }
}
2021-11-01 14:55:12.337  INFO 18176 --- [nio-8080-exec-1] c.r.retry.controller.RetryController     : Sample Api call receieved
2021-11-01 14:55:12.345  INFO 18176 --- [nio-8080-exec-1] c.r.r.config.RetryRegistryEventListener  : #### RetryRegistryEventListener message: 2021-11-01T14:55:12.344325600+05:30[Asia/Calcutta]: Retry 'sample-api', waiting PT10S until attempt '1'. Last attempt failed with exception 'org.springframework.web.client.HttpServerErrorException: 500 INTERNAL_SERVER_ERROR'.
2021-11-01 14:55:12.350  INFO 18176 --- [nio-8080-exec-1] c.r.retry.controller.RetryController     : messsage: 2021-11-01T14:55:12.344325600+05:30[Asia/Calcutta]: Retry 'sample-api', waiting PT10S until attempt '1'. Last attempt failed with exception 'org.springframework.web.client.HttpServerErrorException: 500 INTERNAL_SERVER_ERROR'.
2021-11-01 14:55:22.359  INFO 18176 --- [nio-8080-exec-1] c.r.retry.controller.RetryController     : Sample Api call receieved
2021-11-01 14:55:22.360  INFO 18176 --- [nio-8080-exec-1] c.r.r.config.RetryRegistryEventListener  : #### RetryRegistryEventListener message: 2021-11-01T14:55:22.360672900+05:30[Asia/Calcutta]: Retry 'sample-api', waiting PT10S until attempt '2'. Last attempt failed with exception 'org.springframework.web.client.HttpServerErrorException: 500 INTERNAL_SERVER_ERROR'.
2021-11-01 14:55:22.361  INFO 18176 --- [nio-8080-exec-1] c.r.retry.controller.RetryController     : messsage: 2021-11-01T14:55:22.360672900+05:30[Asia/Calcutta]: Retry 'sample-api', waiting PT10S until attempt '2'. Last attempt failed with exception 'org.springframework.web.client.HttpServerErrorException: 500 INTERNAL_SERVER_ERROR'.

Issue with io.github.resilience4j version 1.7.2 (SpelResolverConfigurationOnMissingBean.spelResolver() method that does not exist)

copy iconCopydownload iconDownload
<dependency>
    <groupId>io.github.resilience4j</groupId>
    <artifactId>resilience4j-core</artifactId>
    <version>1.7.0</version>
</dependency>
<dependency>
    <groupId>io.github.resilience4j</groupId>
    <artifactId>resilience4j-spring-boot2</artifactId>
    <version>1.7.0</version>
</dependency>

Community Discussions

Trending Discussions on resilience4j
  • Resilience4j How to route to fallback method then return back to original method after specific amount of time
  • Building Docker image from spring maven project for arm64 platform
  • Resiliency4j circuit breaker with retry configuration not working
  • Difference between sliding window size and minimum number of calls
  • How to run the SpringBootTest with only a single bean and with included resilience4j annotations
  • Autogenerated OAuth2 login page for AWS Cognito in reactive Spring Boot application fails
  • resilience4j-retry:1.7.1 - does not retry websocket connection
  • Can't get Resilience4j @RateLimiter to work with Spring Boot
  • Error 302 Using FeignClient in Spring Boot Microservices
  • Is there a &quot;Circuit Breaker&quot; for Spring Boot Kafka client?
Trending Discussions on resilience4j

QUESTION

Resilience4j How to route to fallback method then return back to original method after specific amount of time

Asked 2022-Mar-27 at 12:58

I am working with resilience4j and spring boot,

I need to accomplish the below scenario,

  • When I have a failure in the originalMethod
  • After 5 attempts route to the fallback method
  • After a specific time like 5 minutes return back to the originalMethod

I tried with retry as below but does not fit the problem ,

     @Retry(name = "retryService", fallbackMethod = "fallback")
    public String originalMethod(String data) throws InterruptedException {
        //..... call external service 
    }

public String fallback(String data, Throwable t) {
        logger.error("Inside retryfallback, cause – {}", t.toString());
        return "Inside retryfallback method. Some error occurred ";
    }

Added properties

resilience4j.retry:
  instances:
    retryService:
      maxRetryAttempts: 5
      waitDuration: 50000

ANSWER

Answered 2022-Mar-27 at 12:58

I think you can use a circuit breaker for sometime when a failure limit reached to achieve the behavior you want.

By adding @CircuitBreaker(...) annotation and specifying the failureRateThreshold, waitDurationInOpenState and the other needed config properties for that instance.

Source https://stackoverflow.com/questions/71636391

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install resilience4j

You can download it from GitHub, Maven.
You can use resilience4j like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the resilience4j component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

Support

Setup and usage is described in our User Guide.

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Compare HTTP Libraries with Highest Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.