小智..
5
该线程是一个旧的线程,但是共享了我在客户端使用的方法。
我们与服务器进行了基于SOAP的交换,因此我们的类扩展了AbstractSoapInterceptor
在handleMessage()中,我们找到消息的方向(入站或出站),并计算处理所花费的时间。
public void handleMessage(SoapMessage message) throws Fault {
try {
boolean isOutbound = MessageUtils.isOutbound(message);
if (isOutbound) {
// outgoing
long requestSentTime = System.currentTimeMillis();
LOGGER.trace("Sending request to server at {} milliseconds", requestSentTime);
message.getExchange().put(ApplicationConstants.CXF_REQUEST_TIME, requestSentTime);
} else {
// incoming
long requestSentTime = (long) message.getExchange().get(ApplicationConstants.CXF_REQUEST_TIME);
long requestReceiveTime = System.currentTimeMillis();
LOGGER.trace("Receiving request from server at {} milliseconds", requestReceiveTime);
long executionTime = requestReceiveTime - requestSentTime;
LOGGER.info("Server execution time in milliseconds was {}", executionTime);
}
} catch (Exception e) {
LOGGER.error("handleMessage() threw exception {} ", e);
// Log and do nothing
}
}
在Spring应用程序上下文xml中添加了作为传入和传出拦截器的拦截器