Timelimiter Annotation not working (in SpringBoot Application)
See original GitHub issueResilience4j version: 1.7.0
Java version: 16.0.1
I had used the timelimiter annotation with timeout duration as 5 sec in “application.yml”. I was basically testing and trying out all the patterns in resilience 4j , all of them worked fine except the timelimiter. To test it, I had called a thread.sleep for 10 sec and still the result was being printed and the fallBackMethod doesn’t get called.
Here’s the snippet where annotation was done.
@TimeLimiter(name="Time",fallbackMethod="fallBackMethod")
public CompletableFuture<ResponseEntity<?>> listAllAvailableBooks() {
List<Book> books=BRepository.findByPersonId(null);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(books.size()>0) {
return CompletableFuture.completedFuture(new ResponseEntity<>(books,HttpStatus.OK));
}
else {
return CompletableFuture.completedFuture(new ResponseEntity<>("No Books Available Now",HttpStatus.OK));
}
}
public CompletableFuture<ResponseEntity<?>> fallBackMethod(Exception e) {
System.out.println("Here time limit exceed\n");
return CompletableFuture.completedFuture(new ResponseEntity<>(e.getMessage(),HttpStatus.OK));
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
Timeouts with Spring Boot and Resilience4j - Reflectoring
Continuing the Resilience4j journey, this article on Spring Boot TimeLimiter shows when and how to use it to build resilient applications.
Read more >SpringBoot Resilience4j Timelimiter | Timelimiter pattern
You will learn how we can build applications using Resilience4j- Timelimiter implementation in Spring Boot.
Read more >spring test - How to run the SpringBootTest with only a single ...
I would like to run an integration test of a single bean with resilience4j annotated method in a spring boot app.
Read more >Guide to Resilience4j With Spring Boot - Baeldung
Learn how to use the Resilience4j library with a simple Spring Boot application.
Read more >Getting Started - resilience4j
Configuration. You can configure your CircuitBreaker, Retry, RateLimiter, Bulkhead, Thread pool bulkhead and TimeLimiter instances in Spring Boot's application.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The decoration is as follows:
CircuitBreaker ( TimeLimiter ( BulkHead ( method ( ) ) ) )
Thank you so much for the help. I am closing the issue.