SlideShare a Scribd company logo
Simple Groovy example in Mule
Presented by Prince
We often want to stop our flow for sometime and then want
to process it after an interval of time.
In Java we can use Sleep method to hold our thread for a
specific period of time
But how can we use Sleep method in Mule??
.
Here I will show you how ……
Let us consider we have a following Mule flow :-
Now you can see in the above flow the inbound endpoint will pic a file from a
location and put it into another location.
But what if we want to hold the flow for sometime before it put the file in the
outbound location ???
How can we hold the file for an particular interval of time ???
Yes .. We can do it by using sleep method in our flow
So, we need Groovy component to implement sleep method:-
So our Mule flow will be now following :-
This Groovy component will be holding the payload for some time
The corresponding Mule flow will be :-
<file:connector name="File_Global" autoDelete="true" outputAppend="true" streaming="true"
validateConnections="true" doc:name="File"/>
<flow name="Flow1" doc:name="Flow1">
<file:inbound-endpoint path="E:backuptest" responseTimeout="10000" doc:name="File" connector-
ref="File_Global">
<file:filename-regex-filter pattern="abc.txt" caseSensitive="false"/>
</file:inbound-endpoint>
<scripting:component doc:name="Groovy">
<scripting:script engine="Groovy">
<![CDATA[
sleep(3000);
System.out.println("Holding the flow for 3000 ms");
return message.payload;]]>
</scripting:script>
</scripting:component>
<file:outbound-endpoint path="E:backuptestnewfolder" responseTimeout="10000" doc:name="File"/>
</flow>
So, if we start our application again and put the inbound file in the location
E:backuptest , we will get the following in our console :-
And we will get the file in our outbound location E:backuptestnewfolder
after 3000 ms
Hope you enjoyed the simple yet an amazing trick in Mule
Groovy with Mule

More Related Content

PPTX
Groovy example in mule
PPTX
Accessing Mule variables in groovy
PPTX
Simple groovy example in mule
PPTX
Initialize database in Mule part2
PPTX
Cache for community edition
PPT
Simple Java component in Mule
PPTX
Mule quartz
PPTX
Groovy in Mule
Groovy example in mule
Accessing Mule variables in groovy
Simple groovy example in mule
Initialize database in Mule part2
Cache for community edition
Simple Java component in Mule
Mule quartz
Groovy in Mule

What's hot (11)

PPTX
Mule esb How to convert from Json to Xml in 5 minutes
PPTX
Mule message enricher
PPTX
Accessing jms in mule using groovy
PPTX
Timer Interceptor in Mule
PPTX
Getting anypoint studios all versions
PPTX
Deploying and Running in Mule
PPTX
Idempotent filter in Mule
 
PPTX
Encrypting/Decrypting mule
PPTX
Scheduling and monitoring with java in mule
PPTX
Compressing & decompressing in mule
PPTX
Scatter and gather in mule
Mule esb How to convert from Json to Xml in 5 minutes
Mule message enricher
Accessing jms in mule using groovy
Timer Interceptor in Mule
Getting anypoint studios all versions
Deploying and Running in Mule
Idempotent filter in Mule
 
Encrypting/Decrypting mule
Scheduling and monitoring with java in mule
Compressing & decompressing in mule
Scatter and gather in mule
Ad

Viewers also liked (11)

PPTX
Groovy demo
PPTX
Mulesoft Using Groovy Component
PPTX
Using groovy component
PPTX
Cloud hub with mule
PPTX
Mule property placeholder
PPTX
Mule Groovy component
PPTX
Process file one after another
PPTX
Message enricher in mule
PPTX
Using groovy in mule
PDF
Mule esb examples
PPTX
Mule groovy
Groovy demo
Mulesoft Using Groovy Component
Using groovy component
Cloud hub with mule
Mule property placeholder
Mule Groovy component
Process file one after another
Message enricher in mule
Using groovy in mule
Mule esb examples
Mule groovy
Ad

Similar to Groovy with Mule (10)

PPTX
SmpleGroovyexampleinmule
PPTX
Groovy example in mule
PPTX
Simple groovy example in mule
PPTX
Simple groovy example in mule
PPTX
Simple groovy example in mule
PPTX
Simple groovy example in mule
PPTX
Simple groovy example in mule
PPTX
Groovy with mule
PPTX
Groovy with mule
PPTX
Holding a mule flow
SmpleGroovyexampleinmule
Groovy example in mule
Simple groovy example in mule
Simple groovy example in mule
Simple groovy example in mule
Simple groovy example in mule
Simple groovy example in mule
Groovy with mule
Groovy with mule
Holding a mule flow

More from irfan1008 (20)

PPTX
Converting with custom transformer
PPTX
Caching and invalidating with managed store
PPTX
Cache for community edition
PPTX
Mule
PPTX
Validate Soap Request in Mule
PPTX
WebService with VM Mule
PPTX
Xslt in mule
PPT
Developing Oracle Connector Using Mule
PPTX
Send email attachment using smtp in mule esb
PPT
Mule oracle connectors
PPT
Mule google connectors
PPT
Mule execution
PPT
Mule database-connectors
PPT
Mule batch processing
PPT
Mule architecture
PPT
Mule anypoint exchange
PPTX
Mule soap
PPTX
Mule soa
PPT
Mule security saml
PPT
Mule security jaas
Converting with custom transformer
Caching and invalidating with managed store
Cache for community edition
Mule
Validate Soap Request in Mule
WebService with VM Mule
Xslt in mule
Developing Oracle Connector Using Mule
Send email attachment using smtp in mule esb
Mule oracle connectors
Mule google connectors
Mule execution
Mule database-connectors
Mule batch processing
Mule architecture
Mule anypoint exchange
Mule soap
Mule soa
Mule security saml
Mule security jaas

Recently uploaded (20)

PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Approach and Philosophy of On baking technology
PDF
cuic standard and advanced reporting.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
KodekX | Application Modernization Development
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Encapsulation theory and applications.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPT
Teaching material agriculture food technology
NewMind AI Monthly Chronicles - July 2025
Spectral efficient network and resource selection model in 5G networks
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Approach and Philosophy of On baking technology
cuic standard and advanced reporting.pdf
Review of recent advances in non-invasive hemoglobin estimation
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Advanced methodologies resolving dimensionality complications for autism neur...
Chapter 3 Spatial Domain Image Processing.pdf
KodekX | Application Modernization Development
The AUB Centre for AI in Media Proposal.docx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Encapsulation_ Review paper, used for researhc scholars
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation theory and applications.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Teaching material agriculture food technology

Groovy with Mule

  • 1. Simple Groovy example in Mule Presented by Prince
  • 2. We often want to stop our flow for sometime and then want to process it after an interval of time. In Java we can use Sleep method to hold our thread for a specific period of time
  • 3. But how can we use Sleep method in Mule?? .
  • 4. Here I will show you how ……
  • 5. Let us consider we have a following Mule flow :- Now you can see in the above flow the inbound endpoint will pic a file from a location and put it into another location. But what if we want to hold the flow for sometime before it put the file in the outbound location ??? How can we hold the file for an particular interval of time ???
  • 6. Yes .. We can do it by using sleep method in our flow
  • 7. So, we need Groovy component to implement sleep method:-
  • 8. So our Mule flow will be now following :- This Groovy component will be holding the payload for some time
  • 9. The corresponding Mule flow will be :- <file:connector name="File_Global" autoDelete="true" outputAppend="true" streaming="true" validateConnections="true" doc:name="File"/> <flow name="Flow1" doc:name="Flow1"> <file:inbound-endpoint path="E:backuptest" responseTimeout="10000" doc:name="File" connector- ref="File_Global"> <file:filename-regex-filter pattern="abc.txt" caseSensitive="false"/> </file:inbound-endpoint> <scripting:component doc:name="Groovy"> <scripting:script engine="Groovy"> <![CDATA[ sleep(3000); System.out.println("Holding the flow for 3000 ms"); return message.payload;]]> </scripting:script> </scripting:component> <file:outbound-endpoint path="E:backuptestnewfolder" responseTimeout="10000" doc:name="File"/> </flow>
  • 10. So, if we start our application again and put the inbound file in the location E:backuptest , we will get the following in our console :-
  • 11. And we will get the file in our outbound location E:backuptestnewfolder after 3000 ms
  • 12. Hope you enjoyed the simple yet an amazing trick in Mule