I've implemented an advice handler attached to outbound-gateway
components in order to be able to long outgoing HTTP requests before/after. Originally, this was for a Spring-Integration project using MVC/servlet underpinnings. (Original question: Logging http request in Spring integration http outbound gateway )
We are attempting a migration to webflux
/reactive
which means that we are using a webflux:outbound-gateway
in lieu of a http:outbound-gateway
.
The advice handler is an around call in the doInvoke()
method:
public class MyLogger extends AbstractRequestHandlerAdvice {
// ...
@Override
protected Object doInvoke(ExecutionCallback callback, Object target, Message<?> message(
{
// ... logging before the call ...
Object result = callback.execute();
// ... logging after the call ...
return result;
}
}
Whereas I understand that the webflux:outbound-gateway
call itself is supposed to be asynchronous (i.e. no threads waiting on a response), it would seem to me that the advice handler itself must be implemented synchronously (i.e. thread awaiting the response). Am I understanding correctly? Is the advice handler adding synchronicity that wouldn't otherwise be there?
Thanks for any insights on this point.
There is a ReactiveRequestHandlerAdvice
for this particular use-case to wrap a reply Mono
with anything you'd like: https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints.html#reactive-advice