2
votes

Hi I am currently using Spring Integration 4.0.3.I have a requirement of logging the actual request which are coming to the Http Inbound Gateways.The request are to be logged before they are converted into a message by the Http Inbound Messaging Gateway and sent to the gateway request channel.This is how I am trying to achieve this .

  1. Configured a aop pointcut on the HttpRequestHandlingMessagingGateway class handleRequest method.
  2. Configured a custom method Interceptor as an advice and configured the pointcut to execute this advice in the aop config.
  3. In the MethodInterceptor I am retreiving the Request and Response object and logging the request.

But it seems whenever I am applying the aop on handleRequest method the dispatcher servlet is unable to find the handler for any of the url mapping used by all of my http inbound gateways.

I know the same can be achieved through configuring filters in web.xml but I am just curious why this is happening....Please help ...

1

1 Answers

1
votes

Actually you can't proxy HttpRequestHandlingMessagingGateway#handleRequest because it is final.

From other side there is no reason to do so complex AOP work for that logging stuff.

HttpRequestHandlingMessagingGateway populates RequestContextHolder.currentRequestAttributes() as EvaluatationContext variable, so you can put it to MessageHeader and use anywhere in downstream flow:

<int-http:inbound-gateway path="/foo" request-channel="requestChannel">
     <int-http:header name="requestAttributes" expression="#requestAttributes"/>
</int-http:inbound-gateway>

<publish-subscribe-channel id="requestChannel"/>

<logging-channel-adapter channel="requestChannel" 
                expression="headers.requestAttributes.request"/>