2014-12-13 73 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"/> 
相關問題