[Question] Spring Boot Servlet Implementation with @Timelimiter
See original GitHub issueResilience4j version: 1.5.0
Java version: 1.8
Hi,
we still use the Servlet part and not yet the Webflux part of Spring Boot, but still want to benefit from the @TimeLimiter
annotation.
The code of the TimeLimiterAspect
enforces to use a CompletionStage
as return type in case there is no suitable TimeLimiterAspectExt
available.
Since we’re using the servlet implementation methods, which are annotated with the @TimeLimiter
annotation used to be blocking and therefore simply returned the desired type directly.
Now to archive the same goal we simply return a CompletableFuture<MyType>
and the caller of this method calls get()
on the returned CompletableFuture<MyType>
.
Would this be the right approach? Or to you see any undesired side effects when using the @TimeLimiter
annotation like this?
I am asking this because sometimes we face some delays when calling other rest APIs by using Timelimiter, and I am afraid that the timelimiter threading overhead causes these delays?
Unfortunately it is not really easy to make blocking code non blocking.
Thanks in advance for an answer to all these questions 😉
Issue Analytics
- State:
- Created 3 years ago
- Comments:20 (20 by maintainers)
Top GitHub Comments
After your comment GitHub was down. Is there a correlation? 😛
For others, who might also want to use the blocking part of the timelimiter: I introduced a new annotation similar to the io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker annotation and also made use of most of the parts of the io.github.resilience4j.circuitbreaker.configure.CircuitBreakerAspect and simply added a TimeLimiter and Bulkhead to it like so:
Hope that helps someone else with similar demands 😉