您可以通过以下两种方法来做到这一点:
1)使用 计时器拦截器 :
<timer-interceptor />
把它放在流程的尽头
2)使用 自定义拦截器 创建自己的 计时器拦截器 :
在流程结束时使用它:-
<custom-interceptor />
和com.customInterceptor.TimerInterceptor类:-
import org.mule.api.MuleEvent;import org.mule.api.MuleException;import org.mule.api.interceptor.Interceptor;import org.mule.processor.AbstractInterceptingMessageProcessor;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;public class TimerInterceptor extends AbstractInterceptingMessageProcessor implements Interceptor { private static Log logger = LogFactory.getLog(TimerInterceptor.class); public MuleEvent process(MuleEvent event) throws MuleException { long startTime = System.currentTimeMillis(); MuleEvent resultEvent = processNext(event); if (logger.isInfoEnabled()) { long executionTime = System.currentTimeMillis() - startTime; logger.info("Custom Timer : "+resultEvent.getFlowConstruct().getName() + " took " + executionTime + "ms to process event [" + resultEvent.getId() + "]"); } return resultEvent; }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)