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 Video Library
Refcards
Trend Reports

Events

View Events Video Library

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

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Error Handling Inside Kumologica Subflow
  • Techniques You Should Know as a Kafka Streams Developer
  • Overview of C# Async Programming
  • Low Code Serverless Integration With Kafka

Trending

  • A Developer's Guide to Mastering Agentic AI: From Theory to Practice
  • Ensuring Configuration Consistency Across Global Data Centers
  • Unlocking AI Coding Assistants Part 1: Real-World Use Cases
  • Unlocking the Benefits of a Private API in AWS API Gateway

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.

By 
Enrico Rafols Dela Cruz user avatar
Enrico Rafols Dela Cruz
·
Sep. 07, 18 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
8.7K 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.

Related

  • Error Handling Inside Kumologica Subflow
  • Techniques You Should Know as a Kafka Streams Developer
  • Overview of C# Async Programming
  • Low Code Serverless Integration With Kafka

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: