resilience4j | fault tolerance library designed for Java8 | HTTP library

 by   resilience4j Java Version: v2.0.2 License: Apache-2.0

kandi X-RAY | resilience4j Summary

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
    Quality
      Security
        License
          Reuse

            kandi-support Support

              resilience4j has a highly active ecosystem.
              It has 8815 star(s) with 1218 fork(s). There are 209 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 149 open issues and 946 have been closed. On average issues are closed in 11 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 v2.0.2

            kandi-Quality Quality

              resilience4j has 0 bugs and 0 code smells.

            kandi-Security Security

              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.

            kandi-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.

            kandi-Reuse Reuse

              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.

            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 .
            Get all kandi verified functions for this library.

            resilience4j Key Features

            No Key Features are available at this moment for resilience4j.

            resilience4j Examples and Code Snippets

            No Code Snippets are available at this moment for resilience4j.

            Community Discussions

            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 ,

            ...

            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

            QUESTION

            Building Docker image from spring maven project for arm64 platform
            Asked 2022-Mar-24 at 00:10

            I'm in a Spring course, and I have a maven application (downloaded from the course resources) built from spring initializr. I can build a local Docker image with mvn spring-boot:build-image (no Dockerfile in the project). By default a Docker image is built as linux/amd64, but I am working with a M1 Apple Silicon chip (arm64). I've been looking many workarounds but with no success. Lastly, I found that maybe adding a Dockerfile and specifying the platform it would build the image accordingly.

            My goal is to build a docker image for arm64 architecture.

            So, I created a Dockerfile:

            ...

            ANSWER

            Answered 2022-Mar-24 at 00:10

            Building an ARM-based image is not currently possible with mvn spring-boot:build-image, because the Cloud Native Buildpacks builders that Spring Boot integrates with do not support this. This is one of the possible items of focus on the Paketo buildpacks 2022 roadmap, which you can cast votes for.

            CNB documents a work-around for this, but it's not simple to set up and run.

            RUN mvn -f /home/path_to_app/pom.xml spring-boot:build-image -DskipTests

            You would need Docker-in-Docker to make something like this work, since the CNB builder processes that would run inside the Docker container need to talk to the Docker daemon. Regardless, this would not allow you to build an ARM image for the reasons stated above.

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

            QUESTION

            Resiliency4j circuit breaker with retry configuration not working
            Asked 2022-Mar-13 at 18:19

            I am using both @CircuitBreaker and @Retry annotations on a service method. When I apply both the configurations, the retry configurations are not taking affect.

            Below is the configuration:

            ...

            ANSWER

            Answered 2022-Mar-13 at 18:19

            QUESTION

            Difference between sliding window size and minimum number of calls
            Asked 2022-Mar-07 at 04:47

            I am new to circuit breakers and have recently implemented them in one of my services. I was going through the documentation Resilience 4J official documentation and found two properties that we can configure for circuit breakers.

            1. slidingWindowSize
            2. minimumNumberOfCalls

            Both the above properties specify the number of calls that must be made to the services to determine whether the circuit breaker should remain open or should be closed. I need to understand the subtle difference between the two properties and any relationship that they might have with each other? Should they be configured irrespective of each other or should there be a relation between the two?

            Also, is there a relationship between the above two and permittedNumberOfCallsInHalfOpenState. For instance, if I am configuring permittedNumberOfCallsInHalfOpenState as 5 but my slidingWindowSize/minimumNumberOfCalls are configured as 10, then how will the circuit breaker state be re-validated? Because it needs a minimum of 10 requests before it could re-evaluate the new state for circuit breaker but we are permitting only 5 requests when it is in open-state?

            ...

            ANSWER

            Answered 2022-Mar-07 at 04:47

            This answer from the father of Resilience4j helped me:

            In a production system you should not set minimumNumberOfCalls to 1. For testing it is okay, but 3 is better.

            Let's assume you have minimumNumberOfCalls=3, slidingWindowSize = 10 and slidingWindowType = COUNT_BASED: That means the CircuitBreaker is calculating the failure rate and slow call rate based on the last 10 calls, as soon as 3 calls have been recorded.

            Let's assume 2 calls are slow and 1 call is fast: That means the slow call rate is above 50% and the CircuitBreaker will transition to OPEN.

            The minimumNumberOfCalls setting makes even more sense, if slidingWindowType = TIME_BASED and the failure rate is calculated based on the calls from the last N seconds.

            As for the permittedNumberOfCallsInHalfOpenState question, after the wait-duration-in-open-state period is over, it goes into max-wait-duration-in-half-open-state and will allow a max of 5 calls. As long as the threshold is not met/exceeded, the circuit will close. It does not depend on the slidingWindowSize/minimumNumberOfCalls as per here.

            The CircuitBreaker rejects calls with a CallNotPermittedException when it is OPEN. After a wait time duration has elapsed, the CircuitBreaker state changes from OPEN to HALF_OPEN and permits a configurable number of calls to see if the backend is still unavailable or has become available again. Further calls are rejected with a CallNotPermittedException, until all permitted calls have completed. If the failure rate or slow call rate is then equal or greater than the configured threshold, the state changes back to OPEN. If the failure rate and slow call rate is below the threshold, the state changes back to CLOSED.

            P.S If you don't configure any property, the default value is used as per here.

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

            QUESTION

            How to run the SpringBootTest with only a single bean and with included resilience4j annotations
            Asked 2022-Feb-02 at 08:10

            I would like to run an integration test of a single bean with resilience4j annotated method in a spring boot app. My intent is to test resiliency of bean method calls while not loading the full spring context.

            The setup is as follows:

            Dependencies include the following:

            ...

            ANSWER

            Answered 2022-Feb-02 at 08:10

            When dealing with SpringBootTest and @CircuitBreaker, it was sufficient to add @EnableAspectJAutoProxy annotation to the test. After this change, the CircuitBreakerAspect was entertained and the test behaves as expected.

            In order to make @TimeLimiter working as expected, one need to add @Bulkhead annotation to the method as well.

            The updated method looks as follows:

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

            QUESTION

            Autogenerated OAuth2 login page for AWS Cognito in reactive Spring Boot application fails
            Asked 2021-Dec-24 at 17:31

            I am facing an authentication issue in a reactive Spring Boot application using OAuth2 and AWS Cognito. Namely, I configured my app like it's suggested in post here but the problem is that the default login page is failing while authentication attempts or visits. For redirect-uri=http://localhost:8080/login/oauth2/code/cognito I am getting For redirect-uri=https://fitnesstest.auth.eu-central-1.amazoncognito.com/login/cognito I am receiving

            An error was encountered with the requested page.

            Funnily enough, I can receive the tokens via postman for the below client-id, client-secret and callback URL but somehow from the spring boot application, it's not possible.

            my first approach of application.properties look like:

            ...

            ANSWER

            Answered 2021-Dec-24 at 17:31

            Turned out that there is a chance to debug Invalid credentials error for OAuth2 approach. After a suggestion from https://stackoverflow.com/a/62917085/10596295, I debugged the application and realized that there is a problem with the property user-name-attribute. My final version of application.yml looks like this:

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

            QUESTION

            resilience4j-retry:1.7.1 - does not retry websocket connection
            Asked 2021-Dec-13 at 10:59

            I am trying to connect to a remote websocket endpoint (inside spring boot app), and if it throws an Exception I use resilience4j-retry v1.7.7 with JDK 8 to retry connection. However resilience4j-retry tries to connect once and if it fails do not retry. What have I done wrong, the connection is called on ApplicationReadyEvent.

            ...

            ANSWER

            Answered 2021-Dec-13 at 10:59

            Following code worked,

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

            QUESTION

            Can't get Resilience4j @RateLimiter to work with Spring Boot
            Asked 2021-Dec-04 at 20:35

            I can't seem to get Resilience4j @RateLimiter to work with Spring Boot.

            Below is the code

            ...

            ANSWER

            Answered 2021-Dec-04 at 20:35

            I don't have an experience with Resilience4j but it looks like you're trying to use spring-aop here. This works with runtime generated proxy that wraps an original class providing additional functionality (Rate limiting in this case).

            If so, you can't annotate the private method of the class because it won't be detected and processed by the proxy generation mechanism.

            Instead consider creating another bean and expose its functionality as a public method:

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

            QUESTION

            Error 302 Using FeignClient in Spring Boot Microservices
            Asked 2021-Nov-20 at 10:05

            I have a problem with FeignClient. I am deployed Spring Boot applications, I get an error in a call to a specific feign client, the error comes up when I use a registration microservice when wanting to communicate with a specific method of a user microservice, with other methods the problem does not occur, I also have a Eureka server for discovery and a gateway with Spring Cloud Gateway, configured with the configuration for permissions. I have @EnableEurekaClient and @EnableFeignClients in applications and they can be seen on the Eureka server, and implements CircuitBreaker with resilience4j. For testing I use postman.

            for a request:

            Without CircuitBreaker I get this error

            ...

            ANSWER

            Answered 2021-Nov-20 at 10:05

            You have a few options here but let me clarify why this happens. Feign is an HTTP binder for your APIs. In normal cases when you communicate backend-backend, the de-facto accepted HTTP status codes are 2xx to indicate that everything worked as expected. When an API reponds with a 3xx (302 in your case), that indicates a redirect which is usually used to instruct the browser to redirect the user to another page upon doing something.

            Anyway, now that we've cleared why this could happen, let's see why your Feign client behaves this way. All Feign clients have a configuration parameter called follow-redirects. This controls whether upon receiving a 3xx HTTP response, the Feign client should automatically try to call the API specified in the response's Location header.

            By default this parameter is set to true, meaning that redirects will be followed and it will be transparent for you, as a client user. From the exception, I think you somehow disabled it or you might use an HTTP client for which you disabled the redirect following manually.

            Although I can clearly see from your implementation in the preguntarUsuarioExiste method that you're trying to decide whether a user exists in the system or not. In this case the 302 HTTP Found status doesn't make sense even though I understand why you'd want to use that (cause the term reflects that the user exists).

            In this case, I'd simply remove the fixed 302 status with the @ResponseStatus annotation and change the API to return a ResponseEntity instead to resolve the status code dynamically. Something like this:

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

            QUESTION

            Is there a "Circuit Breaker" for Spring Boot Kafka client?
            Asked 2021-Nov-10 at 14:56

            In case that Kafka server is (temporarily) down, my Spring Boot application ReactiveKafkaConsumerTemplate keeps trying to connect unsuccessfully, thus causing unnecessary traffic and messing the log files:

            ...

            ANSWER

            Answered 2021-Nov-10 at 14:47

            See https://kafka.apache.org/documentation/#consumerconfigs_retry.backoff.ms

            The base amount of time to wait before attempting to reconnect to a given host. This avoids repeatedly connecting to a host in a tight loop. This backoff applies to all connection attempts by the client to a broker.

            and https://kafka.apache.org/documentation/#consumerconfigs_reconnect.backoff.max.ms

            The maximum amount of time in milliseconds to wait when reconnecting to a broker that has repeatedly failed to connect. If provided, the backoff per host will increase exponentially for each consecutive connection failure, up to this maximum. After calculating the backoff increase, 20% random jitter is added to avoid connection storms.

            and

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

            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.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/resilience4j/resilience4j.git

          • CLI

            gh repo clone resilience4j/resilience4j

          • sshUrl

            git@github.com:resilience4j/resilience4j.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link