I'm using webflux with netty reactor. The framework allows registering a regular blocking method (e.g that returns a string or some POJO) in a @RestController class. The issue with that is the requests are running on netty's event loop, which you don't want to block. My question is - is there a way to generically offload such methods (by looking at the return type, for example) to a different, dedicated, thread pool?
I've tried doing it in a WebFilter that checks the target method and then uses publishOn
to switch to a different scheduler - this made the filter chain to run on that scheduler, but the method itself was invoked on the eventloop again.
I followed the code path and saw that the Mono.zip
in InvocableHandlerMethod::getMethodArgumentValues
is the point where the eventloop is taking over.
Is there a built-in solution to control which threadpool is running the methods invocation?