spring-cloud / spring-cloud-circuitbreaker

Spring Cloud Circuit Breaker API and Implementations
Apache License 2.0
336 stars 110 forks source link

The default configuration of spring-cloud-starter-circuitbreaker-spring-retry does not work #151

Closed xhc-code closed 2 years ago

xhc-code commented 2 years ago

surroundings:

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-circuitbreaker-resilience4j</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-circuitbreaker-spring-retry</artifactId>
            <version>2.0.3</version>
        </dependency>

spring.cloud-version:2021.0.3 JDK:11

Describe the bug

When I use Spring-retry to retry, I don't understand what the default and specific configuration of spring-retry mentioned on the official website is, because when I use the @Retryable annotation, the relevant configuration information is read from the annotation. taken. This will do nothing if spring-retry is used like this image

sprign-retry doc:https://docs.spring.io/spring-cloud-circuitbreaker/docs/current/reference/html/#default-configuration-2

Sample If possible, please provide a test case or sample application that reproduces the problem. This makes it much easier for us to diagnose the problem and to verify that we have fixed it.

ryanjbaxter commented 2 years ago

Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

xhc-code commented 2 years ago

Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

Simple code repository: https://github.com/starSmallDream/SpringCloudRetryDemo.git

The first problem is that accessing the demo project via /hello does not retry. Not sure where the problem is.

The second question is, circuitbreaker-resilience4j and circuitbreaker-retry dependencies look to me as if retry contains a relationship of resilience4j?

The third question is about SpringRetry, the default configuration and specific configuration of circuitbreaker-retry, which are invalid when used, and do not play the role of retry.

The fourth question is is spring-cloud-starter-circuitbreaker-spring-retry the way to use @Retryable annotation? If the @Retryable annotation is used, what is the effect of the default configuration and specific configuration of circuitbreaker-retry? Because the meta information of the configuration Retryable annotation is read when retrying.

The fifth question is, if 3 and 4 do not represent a problem, please answer this. How to use spring-cloud-starter-circuitbreaker-spring-retry?

Thanks for your answer. Because all the Internet searches are about the independent use of spring-retry, it does not answer my question.

cloud-spring-retry documentation address: https://docs.spring.io/spring-cloud-circuitbreaker/docs/current/reference/html/#configuring-spring-retry-circuit-breakers

xhc-code commented 2 years ago

The reason for the first problem is found, because the @Retryable annotation does not have the function of circuit breaker, only the function of retrying after throwing an exception.

xhc-code commented 2 years ago

The reason for the first problem is found, because the @Retryable annotation does not have the function of circuit breaker, only the function of retrying after throwing an exception.

But the default configuration and specific configuration set have no effect because the timeout period has been set.

xhc-code commented 2 years ago

The third question, I seem to have found the reason. When I use spring-cloud-starter-circuitbreaker-spring-retry I should use the io.github.resilience4j.retry.annotation.Retry annotation, right? image

Because @EnableRetry annotation and @Retryable annotation are provided by spring-retry, the @Retryable annotation will not work for spring-cloud-starter-circuitbreaker's java configuration, right?

xhc-code commented 2 years ago

The third question, I seem to have found the reason. When I use spring-cloud-starter-circuitbreaker-spring-retry I should use the io.github.resilience4j.retry.annotation.Retry annotation, right? image

Because @EnableRetry annotation and @Retryable annotation are provided by spring-retry, the @Retryable annotation will not work for spring-cloud-starter-circuitbreaker's java configuration, right?

still doesn't work

xhc-code commented 2 years ago

The relevant documentation and homepage about this spring-cloud-starter-circuitbreaker-spring-retry starter are not accessible, is there any reason for this? image

Home page https://spring.io/spring-cloud/spring-cloud-circuitbreaker/spring-cloud-starter-circuitbreaker/spring-cloud-starter-circuitbreaker-spring-retry Source code https://github.com/spring-cloud/spring-cloud-build/spring-cloud-circuitbreaker/spring-cloud-starter-circuitbreaker/spring-cloud-starter-circuitbreaker-spring-retry

xhc-code commented 2 years ago

Is it so inactive here?

ryanjbaxter commented 2 years ago

Please be aware that we have many projects to manage and have time constraints. Patience is appreciated.

I think is best if we start with an example:

Here is how Spring Retry is intended to be used with Spring Cloud CircuitBreaker https://github.com/spring-cloud/spring-cloud-circuitbreaker/blob/main/spring-cloud-circuitbreaker-spring-retry/src/test/java/org/springframework/cloud/circuitbreaker/springretry/SpringRetryCircuitBreakerIntegrationTest.java

Let me know if that helps clarify things and what other questions you have.

xhc-code commented 2 years ago

Understood, thanks