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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Error Handling Inside Kumologica Subflow
  • Techniques You Should Know as a Kafka Streams Developer
  • Diagnosing Test Failures at Scale: Correlating Execution Evidence Across Ephemeral Runners
  • AI Agents Need an Identity Plane: Rethinking Enterprise Authorization for Autonomous Software

Trending

  • Using the Anthropic Evaluation Tool to Check the Claude Code Plugin Efficiency
  • The SDLC After AI
  • How Predictive Analytics Became a Key Enabler for the Future of QA
  • The Real Cost of Change in Software Development

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

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
·
Sep. 07, 18 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
9.0K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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
  • Diagnosing Test Failures at Scale: Correlating Execution Evidence Across Ephemeral Runners
  • AI Agents Need an Identity Plane: Rethinking Enterprise Authorization for Autonomous Software

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

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 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook