2016-08-02 52 views
1

我的要求是要通过计算如JDBC,Web服务等外部资源所消耗的总时间,端点信息

我在添加请求处理程序,建议链所需的端点并计算时间。它完美的作品。 我也必须添加端点组件的标识符。有什么办法通过建议类获得端点ID。

例:

<int-jdbc:stored-proc-outbound-gateway id="myProcID" request-channel="myChannel" data-source="dataSource" 
.... 
     <int-jdbc:request-handler-advice-chain> 
      <ref bean="statsAdvice" /> 
     </int-jdbc:request-handler-advice-chain> 
    </int-jdbc:stored-proc-outbound-gateway> 

我能在咨询类的JDBC端点ID?请建议。 在此先感谢。

建议类扩展了AbstractRequestHandlerAdvice,当我尝试转换时 NamedComponent component =(NamedComponent)target;

我得到下面的异常 - org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.integration.jdbc.StoredProcOutboundGateway#0]; nested exception is java.lang.ClassCastException: org.springframework.integration.handler.AbstractReplyProducingMessageHandler$AdvisedRequestHandler

修复工作正常使用4.3.2版本:

((AbstractReplyProducingMessageHandler.RequestHandler) target).getAdvisedHandler().getComponentName(); 

回答

0

如果你的建议延长AbstractRequestHandlerAdvice目标对象是可作为doInvoke参数 - 见the javadocs

将其转换为NamedComponent并致电getComponentName()

如果您直接实施了MethodInterceptor,请使用invocation.getThis()获取对处理程序的引用。

+0

请参阅编辑的问题.. –

+0

您的帮助是高度赞赏。 –

+0

哦,是的;抱歉;我忘记了这个包装 - 我们应该提供访问它的代表;请打开一个改进[JIRA问题](https://jira.spring.io/browse/INT)。 –