问题
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