【问题标题】:Spring Integration Http Inbound Gateway Request LoggingSpring 集成 Http 入站网关请求日志记录
【发布时间】:2014-12-13 20:56:41
【问题描述】:

您好,我目前正在使用 Spring Integration 4.0.3。我需要记录到达 Http Inbound Gateways 的实际请求。在将请求通过 Http Inbound Messaging 转换为消息之前记录该请求网关并发送到网关请求通道。这就是我试图实现的方式。

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

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

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

【问题讨论】:

    标签: spring-integration


    【解决方案1】:

    其实你不能代理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"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-10
      • 1970-01-01
      • 2014-06-13
      • 1970-01-01
      • 2012-09-12
      相关资源
      最近更新 更多