Expose Http Response time in Mule ESB

岁酱吖の 提交于 2019-12-23 02:22:02

问题


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.


回答1:


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

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");
 }

Here is the response

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




回答2:


What you actually need to leverage to take some statistics around the endpoints are server notifications, please see the following documentation page:

https://developer.mulesoft.com/docs/display/current/Mule+Server+Notifications

Check out the endpoint notification.



来源:https://stackoverflow.com/questions/31579852/expose-http-response-time-in-mule-esb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!