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

Related

  • Error Handling Inside Kumologica Subflow
  • Techniques You Should Know as a Kafka Streams Developer
  • Automating Power Automate: How to Ensure Cloud Flows Are Active After Every Pipeline Deployment
  • A Deep Dive into Tracing Agentic Workflows (Part 1)

Trending

  • Top Java Security Vulnerabilities and How to Prevent Them in Modern Java
  • Testing AI-Infused Apps: A Dual-Layer Framework for AI Quality Assurance
  • The ORM Is Over: AI-Written SQL Is the New Data Access Layer
  • Observability for Agents and Workflows: Tracing Prompts, Tool Calls, and Business Outcomes End-to-End

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.9K 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
  • Automating Power Automate: How to Ensure Cloud Flows Are Active After Every Pipeline Deployment
  • A Deep Dive into Tracing Agentic Workflows (Part 1)

Partner Resources

×

Comments

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

  • 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