Small question regarding Java SpringBoot Webflux with Resilience4J (not Spring Cloud Circuit Breaker) please.
I have the following straightforward:
@TimeLimiter(name = "methodOne", fallbackMethod = "fallbackMethod")
public Mono<String> methodOne(@RequestParam(value = "name", defaultValue = "World") String name) {
return WebClient.builder().baseUrl("http://localhost:8081/serviceBgreeting?name=" + name).build().get().retrieve().bodyToMono(String.class);
}
@TimeLimiter(name = "methodTwo", fallbackMethod = "fallbackMethod")
public Mono<String> methodTwo(@RequestParam(value = "name", defaultValue = "World") String name) {
return WebClient.builder().baseUrl("http://localhost:8082/anotherMethodTwo?name=" + name).build().get().retrieve().bodyToMono(String.class);
}
And one same callee fallbackMethod, shared by all callers, as:
public Mono<Object> fallBackMethod(Exception exception) {
System.out.println("For debug purpose, I need to know what is the exact method falling back to this fallback method");
return //the fallback thing needed;
What is the best way to retrieve which one of the two methods methodOne or methodTwo was actually the trigger of this fallback please?
I have some 1000+ methods with this pattern, so I cannot just create 1000+ fallback methods. (like methodOne falls to fallbackOne, methodTwo to fallbackTwo etc..., I cannot)
I am sure there is a smart way to get the method name triggering the fallback.
Tried StackWalker which gives only (fallBackMethod, invoke, fallback, lambda$reactorOnErrorResume$1, onError, etc...) But not the method triggering the fallBack.
A bit of help please.
Thank you