2014-12-13 124 views
2

嗨我目前正在使用Spring Integration 4.0.3.I有一个记录实际请求来到Http入站网关的要求。请求被记录之前,它们被转换成由Http入站消息网关发送并发送到网关请求通道的消息。这就是我试图实现这一点的方式。春季集成Http入站网关请求日志记录

  1. 在HttpRequestHandlingMessagingGateway类的handleRequest方法上配置aop切入点。
  2. 配置一个自定义方法拦截器作为建议,并配置切入点在aop配置中执行此建议。
  3. 在MethodInterceptor中,我正在检索请求和响应对象并记录请求。

但是,似乎每当我在handleRequest方法上应用aop时,调度程序servlet都无法找到所有我的http入站网关使用的任何url映射的处理程序。

我知道同样可以通过配置在web.xml中的过滤器来实现,但我只是好奇,为什么会这样....请帮助...

回答

0

其实你不能代理HttpRequestHandlingMessagingGateway#handleRequest,因为它是final

从另一方面来说,没有理由为测井的东西做复杂的AOP工作。

HttpRequestHandlingMessagingGateway填充RequestContextHolder.currentRequestAttributes()EvaluatationContext变量,所以你可以把它MessageHeader和下游流量在任何地方使用:

<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"/> 
相关问题