Skip to content
Advertisement

Java + Webflux + Resilience4j: Name of the method triggering the fallBack method

Small question regarding Java SpringBoot Webflux with Resilience4J (not Spring Cloud Circuit Breaker) please.

I have the following straightforward:

JavaScript

And one same callee fallbackMethod, shared by all callers, as:

JavaScript

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

Advertisement

Answer

Can you try Executing this from fallbackMethod We are collecting the list of available methods in the executing call and from stack trace checking if the very recent caller is present.

JavaScript

This is printing something similar to this

JavaScript

We can extract the method name from here.

This is how my caller looks like

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement