Issue
I was looking at a post from 2014 about using Spring AOP for logging HTTP requests/replies:
Spring integration + logging response time for http adapters(or any endpoint)
To this end, I tried this AOP configuration:
<aop:config >
<aop:aspect id="myAspect" ref="inboundOutboundHttpLogging">
<aop:pointcut id="handleRequestMessageMethod"
expression="execution(* org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleRequestMessage(*))
and
args(message))" />
<aop:before method="requestMessageSent" pointcut-ref="handleRequestMessageMethod" arg-names="message"/>
</aop:aspect>
</aop:config>
Is there perhaps a newer way of using AOP for logging HTTP requests? I want to avoid having to put per-request logging (i.e. outbound-gateway advice on each gateway).
Thanks for any pointers.
Solution
The handleRequestMessage()
is essentially an input message to this gateway and output. So, if you don't like implementing an AbstractRequestHandlerAdvice
and adding it into each your gateway via their <request-handler-advice-chain>
, then consider to use a <wire-tap>
for input and output channels of those gateway.
You may implement, though, a BeanPostProcessor.postProcessBeforeInitialization()
to add your custom AbstractRequestHandlerAdvice
into those HTTP gateways you are interested in.
My point is that <aop:aspect>
you are presenting us really might lead to some unexpected behavior, like that final
method concern you have edit out from your question...
Answered By - Artem Bilan
Answer Checked By - Marie Seifert (JavaFixing Admin)