DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Mule 3.9: Using Timer Interceptor [Snippet]

Let's take a look at how to calculate the flow execution time without using any custom code or logic in Mule.

Enrico Rafols Dela Cruz user avatar by
Enrico Rafols Dela Cruz
·
Sep. 07, 18 · Tutorial
Like (1)
Save
Tweet
Share
7.94K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, I will show you how to calculate the flow execution time without using any custom code or logic in Mule. Using Timer Interceptor, we are able to see the execution time of a private flow in Mule logs. This is very helpful when it comes to checking the performance of your flows, especially when doing performance testing.

<timer-interceptor doc:name="Timer Interceptor"/> 

Using the Timer-Interceptor:

Image title

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd">
    <flow name="dzone-mule-appsFlow">
        <poll doc:name="Runs every 10 seconds">
            <fixed-frequency-scheduler frequency="10000"/>
            <logger level="INFO" doc:name="Logger" message="#[message.rootId] - Start Of Process"/>
        </poll>
        <timer-interceptor doc:name="Timer Interceptor"/> 
        <flow-ref name="sf-main-logic" doc:name="sf-main-logic"/>
        <logger message="#[message.rootId] - End Of Process" level="INFO" doc:name="Logger"/>
    </flow>
    <sub-flow name="sf-main-logic">
        <scripting:transformer doc:name="Groovy Sleep(10000)">
            <scripting:script engine="Groovy"><![CDATA[sleep(5000);]]></scripting:script>
        </scripting:transformer>
    </sub-flow>
</mule>

For more details creating custom interceptor, check this out: https://docs.mulesoft.com/mule-user-guide/v/3.9/using-interceptors#timer-interceptor

Testing:

The Timer Interceptor logged the flow name and the captured process duration.

Image title

Thanks for reading. Please let me know if you have any questions in the comments section. 

Flow (web browser) code style Execution (computing)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Stop Using Spring Profiles Per Environment
  • What Are the Benefits of Java Module With Example
  • Distributed Tracing: A Full Guide
  • Kubernetes-Native Development With Quarkus and Eclipse JKube

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: