TimeLimiter for methods returning void
See original GitHub issueI am having to implement TimeLimiter
for a method which has void
return type, but I noticed that TimeLimiter
only has decorateFutureSupplier
which cannot take a method which returns void
. Can you please let me know how this can be implemented?
My situation is that the method I am using from an external library and I cannot change its signature. So I will really appreciate any help on this topic.
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Resilience4j with spring boot - java - Stack Overflow
Earlier, i used CircuitBreaker and Retry annotations with void method. It worked. But Timelimiter was not working.
Read more >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 >TimeLimiter (Guava: Google Core Libraries for Java 22.0 API)
Returns an instance of interfaceType that delegates all method calls to the target object, enforcing the specified time limit on each call. void...
Read more >Mocking Void Methods with Mockito - Baeldung
See how to mock methods that return void using Mockito.
Read more >OperationalConfig (Oracle Fusion Middleware Java API Reference ...
Sets default sizelimit, maximum number of entities to be returned in search methods. void, setTimeLimit(int timeLimit). Sets default timelimit, maximum time ...
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 FreeTop 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
Top GitHub Comments
for point 1: this was typo , it was meant to be waitDurationInOpenState , it is updated now on the docs for point 2 : after u add the r4j spring boot starter and the config in ur yaml file , you just inject CircuitBreakerRegistry bean in your spring managed service/component then get the target circuit breaker by its instance name :
io.github.resilience4j.circuitbreaker.CircuitBreaker circuitBreaker = circuitBreakerRegistry.circuitBreaker(instanceName);
Depends on the decoration order and your CircuitBreakerConfig. In @hexmind example, yes. But you could also ignore TimeoutExceptions