在Mule ESB中公开Http响应时间 [英] Expose Http Response time in Mule ESB

查看:270
本文介绍了在Mule ESB中公开Http响应时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以获取MULE中端点的响应时间吗? 例子是m子中的Http连接器,我需要获取被调用端点的响应时间.

Is there any way to get the response time of an endpoint in MULE? Example is the Http Connector in mule, I need to get the response time of the invoked endpoint.

推荐答案

我能够使用Mule Server Notification解决问题.

I was able to solve my problem by using Mule Server Notification.

有一个MessageProcessorNotificationListener接口,它可以侦听消息处理器的PRE/POST调用.

There is an interface MessageProcessorNotificationListener which can listen to PRE/POST invoke of a message processor.

我已经使用以下代码获得了消息处理器的响应时间.

I have achieved to get the response time of an message processor using the following code.

  long startTime;
 if (m.getAction() ==  MessageProcessorNotification.MESSAGE_PROCESSOR_PRE_INVOKE) 
 {
     startTime = System.currentTimeMillis();
 }
 if (m.getAction() ==     MessageProcessorNotification.MESSAGE_PROCESSOR_POST_INVOKE) 
 {
     long executionTime = System.currentTimeMillis() - startTime;
     AbstractEndpoint ep = (AbstractEndpoint) proc;
     log.info("Http call to : "+ ep.getName() + " took " + executionTime + "ms response time");
 }

这是回应

Http呼叫:endpoint.http.google.com.80花费了224ms的响应时间.

Http call to : endpoint.http.google.com.80 took 224ms response time.

这篇关于在Mule ESB中公开Http响应时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆