【发布时间】:2016-09-20 15:44:52
【问题描述】:
我的要求是计算外部资源(如 jdbc、web 服务等)消耗的总时间,
我在所需的端点中添加了 request-handler-advice-chain 并计算了时间。它完美地工作。 我还必须添加端点组件的标识符。有什么方法可以通过建议类获取端点 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 吗?请建议。 提前致谢。
Advice 类扩展 AbstractRequestHandlerAdvice 并且当我尝试强制转换时 NamedComponent 组件 = (NamedComponent) 目标;
我收到以下异常 - 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();
【问题讨论】: