Comments (7)
maxRetryAttempts
has been changed to maxAttempts
Please don't mix imperative and reactive code.
If you want to print something on error, then please use onErrorContinue()
or doOnError()
.
from resilience4j-spring-boot2-demo.
@RobWin My intention is not to print something on error actually
I wanted to try the @Retry annotation for fluxFailure and monoFailure endpoints from this resilience4j-spring-boot2-demo example for BackendA controller and it's not working after the exception is thrown from BackendA service methods for fluxFailure and monoFailure should have been re-attempted
from resilience4j-spring-boot2-demo.
How do you check that the retry is not working in your case?
from resilience4j-spring-boot2-demo.
@RobWin
I am running an application in my local at port 9080 and I am trying to hit the below endpoints so when I hit this URL I am expecting multiple times "IOException("BAM!")" exception in console logs.
http://localhost:9080/backendA/fluxFailure
http://localhost:9080/backendA/monoFailure
same as when I hit URL I get multiple times "HttpServerErrorException" in console logs
http://localhost:9080/backendA/failure
from resilience4j-spring-boot2-demo.
I can't replicate this issue in this demo project. It works fine.
I can't tell you what you are doing wrong without seeing your project,
The exception is only shown once, when the last retry attempt fails:
2021-03-26 08:30:00.399 INFO 16172 --- [ctor-http-nio-2] io.github.robwin.Application : 2021-03-26T08:30:00.399458600+01:00[Europe/Berlin]: CircuitBreaker 'backendA' recorded an error: 'java.io.IOException: BAM!'. Elapsed time: 2 ms
2021-03-26 08:30:00.411 INFO 16172 --- [ctor-http-nio-2] io.github.robwin.Application : 2021-03-26T08:30:00.411787+01:00[Europe/Berlin]: Retry 'backendA', waiting PT0.1S until attempt '1'. Last attempt failed with exception 'java.io.IOException: BAM!'.
2021-03-26 08:30:00.516 INFO 16172 --- [ parallel-1] io.github.robwin.Application : 2021-03-26T08:30:00.516647200+01:00[Europe/Berlin]: CircuitBreaker 'backendA' recorded an error: 'java.io.IOException: BAM!'. Elapsed time: 0 ms
2021-03-26 08:30:00.516 INFO 16172 --- [ parallel-1] io.github.robwin.Application : 2021-03-26T08:30:00.516647200+01:00[Europe/Berlin]: Retry 'backendA', waiting PT0.1S until attempt '2'. Last attempt failed with exception 'java.io.IOException: BAM!'.
2021-03-26 08:30:00.621 INFO 16172 --- [ parallel-2] io.github.robwin.Application : 2021-03-26T08:30:00.621145500+01:00[Europe/Berlin]: CircuitBreaker 'backendA' recorded an error: 'java.io.IOException: BAM!'. Elapsed time: 0 ms
2021-03-26 08:30:00.622 INFO 16172 --- [ parallel-2] io.github.robwin.Application : 2021-03-26T08:30:00.622147500+01:00[Europe/Berlin]: Retry 'backendA' recorded a failed retry attempt. Number of retry attempts: '3'. Giving up. Last exception was: 'java.io.IOException: BAM!'.
2021-03-26 08:30:00.636 ERROR 16172 --- [ parallel-2] a.w.r.e.AbstractErrorWebExceptionHandler : [9c67d604-1] 500 Server Error for HTTP GET "/backendA/monoFailure"
java.io.IOException: BAM!
at io.github.robwin.service.BackendAService.monoFailure(BackendAService.java:95) ~[main/:na]
from resilience4j-spring-boot2-demo.
@RobWin it's my bad in understanding, I was expecting the complete method would retry in case of monoFailure()/fluxFailure() as it does in case of failure()
@Override
@CircuitBreaker(name = BACKEND_A)
@Bulkhead(name = BACKEND_A)
@Retry(name = BACKEND_A)
public String failure() {
log.info("execute {} method", "failure");
throw new HttpServerErrorException(HttpStatus.INTERNAL_SERVER_ERROR, "This is a remote exception");
}
@Override
@CircuitBreaker(name = BACKEND_A)
@Bulkhead(name = BACKEND_A)
@Retry(name = BACKEND_A)
public Mono<String> monoFailure() {
log.info("execute {} method", "monoFailure");
return Mono.error(new IOException("BAM!"));
}
failure() -- Logs ("execute failure method" is printed 3 times)
2021-03-26 11:25:06.338 INFO 35032 --- [nio-9080-exec-2] i.github.robwin.service.BackendAService : execute failure method
2021-03-26 11:25:06.354 INFO 35032 --- [nio-9080-exec-2] io.github.robwin.Application : 2021-03-26T11:25:06.351760500-05:00[America/Chicago]: CircuitBreaker 'backendA' recorded an error: 'org.springframework.web.client.HttpServerErrorException: 500 This is a remote exception'. Elapsed time: 27 ms
2021-03-26 11:25:06.385 INFO 35032 --- [nio-9080-exec-2] io.github.robwin.Application : 2021-03-26T11:25:06.385759200-05:00[America/Chicago]: Retry 'backendA', waiting PT0.1S until attempt '1'. Last attempt failed with exception 'org.springframework.web.client.HttpServerErrorException: 500 This is a remote exception'.
2021-03-26 11:25:06.496 INFO 35032 --- [nio-9080-exec-2] i.github.robwin.service.BackendAService : execute failure method
2021-03-26 11:25:06.497 INFO 35032 --- [nio-9080-exec-2] io.github.robwin.Application : 2021-03-26T11:25:06.497373500-05:00[America/Chicago]: CircuitBreaker 'backendA' recorded an error: 'org.springframework.web.client.HttpServerErrorException: 500 This is a remote exception'. Elapsed time: 1 ms
2021-03-26 11:25:06.499 INFO 35032 --- [nio-9080-exec-2] io.github.robwin.Application : 2021-03-26T11:25:06.498372700-05:00[America/Chicago]: Retry 'backendA', waiting PT0.1S until attempt '2'. Last attempt failed with exception 'org.springframework.web.client.HttpServerErrorException: 500 This is a remote exception'.
2021-03-26 11:25:06.599 INFO 35032 --- [nio-9080-exec-2] i.github.robwin.service.BackendAService : execute failure method
2021-03-26 11:25:06.599 INFO 35032 --- [nio-9080-exec-2] io.github.robwin.Application : 2021-03-26T11:25:06.599418900-05:00[America/Chicago]: CircuitBreaker 'backendA' recorded an error: 'org.springframework.web.client.HttpServerErrorException: 500 This is a remote exception'. Elapsed time: 0 ms
2021-03-26 11:25:06.601 INFO 35032 --- [nio-9080-exec-2] io.github.robwin.Application : 2021-03-26T11:25:06.601421700-05:00[America/Chicago]: Retry 'backendA' recorded a failed retry attempt. Number of retry attempts: '3'. Giving up. Last exception was: 'org.springframework.web.client.HttpServerErrorException: 500 This is a remote exception'.
2021-03-26 11:25:06.611 ERROR 35032 --- [nio-9080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.client.HttpServerErrorException: 500 This is a remote exception] with root cause
monoFailure() -- Logs ("execute monoFailure method" printed only once)
2021-03-26 11:53:01.237 INFO 28972 --- [nio-9080-exec-1] i.github.robwin.service.BackendAService : execute monoFailure method
2021-03-26 11:53:01.324 INFO 28972 --- [nio-9080-exec-1] io.github.robwin.Application : 2021-03-26T11:53:01.323628700-05:00[America/Chicago]: CircuitBreaker 'backendA' recorded an error: 'java.io.IOException: BAM!'. Elapsed time: 8 ms
2021-03-26 11:53:01.341 INFO 28972 --- [nio-9080-exec-1] io.github.robwin.Application : 2021-03-26T11:53:01.341630600-05:00[America/Chicago]: Retry 'backendA', waiting PT0.1S until attempt '1'. Last attempt failed with exception 'java.io.IOException: BAM!'.
2021-03-26 11:53:01.465 INFO 28972 --- [ parallel-1] io.github.robwin.Application : 2021-03-26T11:53:01.464684-05:00[America/Chicago]: CircuitBreaker 'backendA' recorded an error: 'java.io.IOException: BAM!'. Elapsed time: 0 ms
2021-03-26 11:53:01.466 INFO 28972 --- [ parallel-1] io.github.robwin.Application : 2021-03-26T11:53:01.465678700-05:00[America/Chicago]: Retry 'backendA', waiting PT0.1S until attempt '2'. Last attempt failed with exception 'java.io.IOException: BAM!'.
2021-03-26 11:53:01.569 INFO 28972 --- [ parallel-2] io.github.robwin.Application : 2021-03-26T11:53:01.568634300-05:00[America/Chicago]: CircuitBreaker 'backendA' recorded an error: 'java.io.IOException: BAM!'. Elapsed time: 0 ms
2021-03-26 11:53:01.574 INFO 28972 --- [ parallel-2] io.github.robwin.Application : 2021-03-26T11:53:01.573870-05:00[America/Chicago]: Retry 'backendA' recorded a failed retry attempt. Number of retry attempts: '3'. Giving up. Last exception was: 'java.io.IOException: BAM!'.
2021-03-26 11:53:01.629 ERROR 28972 --- [nio-9080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] threw exception
java.io.IOException: BAM!
from resilience4j-spring-boot2-demo.
@mvonga @RobWin
I'm facing exactly the same issue, how did you solve the problem?
For the monofailure, I can only see one attempt logged. Even I try to add log to doOnError, still only one attempt.
from resilience4j-spring-boot2-demo.
Related Issues (20)
- Log: Reactor and RxJava2 HOT 5
- fallBackMethod is not activated
- How to change the config resilience4j from applicaton.yml to file application.properites HOT 2
- Getting the issue -java.lang.NoSuchFieldError: entryMap HOT 4
- Broken tests (Java 11) HOT 4
- Error in AbstractIntegrationTest HOT 3
- Description of the options found in YML properties as documentation HOT 3
- building from the command line fails. HOT 2
- Query with instance in Prometheus HOT 1
- No class Def Error - Caused by: java.lang.ClassNotFoundException: io.github.resilience4j.spelresolver.SpelResolver HOT 2
- Caused by: java.lang.IllegalArgumentException: Could not find class [org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration] HOT 11
- Odd gradle issues bringing in old version for spring-boot2 dependency. HOT 1
- Not able to fetch data from some endpoints HOT 1
- Getting error to make an upgrade to at least Gradle 6.8 HOT 1
- spring boot integration test is failing HOT 1
- How to keep different CircuitBreakerConfiguration for multiple circuit breakers? HOT 8
- Provide aspectj definitions HOT 1
- Defining state in application.yml HOT 2
- how to check thread-pool-bulkhead health? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from resilience4j-spring-boot2-demo.