SlideShare a Scribd company logo
Simple Groovy example in Mule
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 in Mule

More Related Content

PPTX
Simple groovy example in mule
PPTX
Groovy with Mule
PPTX
Accessing Mule variables in groovy
PPTX
Mule quartz
PPTX
Mule message enricher
PPTX
Cache for community edition
PPTX
Mulesoft Using Groovy Component
PPTX
Groovy example in mule
Simple groovy example in mule
Groovy with Mule
Accessing Mule variables in groovy
Mule quartz
Mule message enricher
Cache for community edition
Mulesoft Using Groovy Component
Groovy example in mule

What's hot (10)

PPTX
Stored procedure in Mule
PPTX
Mule with stored procedure
PPTX
Scatter and gather in mule
PPTX
Initialize database in Mule part2
PPTX
Accessing jms in mule using groovy
PPTX
Encrypting/Decrypting mule
PPT
Simple Java component in Mule
PPTX
Deploying and Running in Mule
PPTX
Idempotent filter in Mule
 
PPTX
Timer Interceptor in Mule part 2
Stored procedure in Mule
Mule with stored procedure
Scatter and gather in mule
Initialize database in Mule part2
Accessing jms in mule using groovy
Encrypting/Decrypting mule
Simple Java component in Mule
Deploying and Running in Mule
Idempotent filter in Mule
 
Timer Interceptor in Mule part 2
Ad

Viewers also liked (20)

PPT
Mule batch processing
PPTX
Webservice vm in mule
PPTX
Introduction to mule esb
PPTX
Mule velocity
PPTX
Mule soap
PPTX
Documantation with mule
PPTX
Mapping and listing with mule
PPTX
How to use expression filter
PPT
Mule oracle connectors
PPT
Mule anypoint exchange
PDF
Damaging damzelz' no.1
PPTX
Soap request in mule
PPT
Anypoint data gateway
PPTX
Mmc rest api user groups
PPT
Mule security-jaas
PDF
CSP Review Report_Final (1)
PPT
Mule technology
PPTX
Creating dynamic json in mule
PPTX
Send email attachment using smtp in mule esb
PPTX
xslt in mule
Mule batch processing
Webservice vm in mule
Introduction to mule esb
Mule velocity
Mule soap
Documantation with mule
Mapping and listing with mule
How to use expression filter
Mule oracle connectors
Mule anypoint exchange
Damaging damzelz' no.1
Soap request in mule
Anypoint data gateway
Mmc rest api user groups
Mule security-jaas
CSP Review Report_Final (1)
Mule technology
Creating dynamic json in mule
Send email attachment using smtp in mule esb
xslt in mule
Ad

Similar to Groovy in Mule (20)

PPTX
SmpleGroovyexampleinmule
PPTX
Groovy with mule
PPTX
Groovy with mule
PPTX
Holding a mule flow
PPTX
Handle File on mule
PPTX
Schedule and monitor in mule
PPTX
Using spring scheduler mule
PPTX
Using spring task scheduler in java in mule
PPTX
Scheduling and monitoring with java in mule
PPTX
Mule with stored procedure
PPTX
Mule stored procedure
PPTX
Mule with stored procedure
PPTX
Cache for community edition
PPTX
Cache for community edition
PPTX
Cache for community edition
PPTX
Community edition Cache
PPTX
Cache for community edition
PPTX
Cache community edition
PPTX
Cache for community edition
PPTX
Cache for community edition
SmpleGroovyexampleinmule
Groovy with mule
Groovy with mule
Holding a mule flow
Handle File on mule
Schedule and monitor in mule
Using spring scheduler mule
Using spring task scheduler in java in mule
Scheduling and monitoring with java in mule
Mule with stored procedure
Mule stored procedure
Mule with stored procedure
Cache for community edition
Cache for community edition
Cache for community edition
Community edition Cache
Cache for community edition
Cache community edition
Cache for community edition
Cache for community edition

More from Praneethchampion (14)

PPT
Mule execution
PPTX
PPTX
Mule esb stripe
PPTX
Dataweave
PPTX
Mule for each scope header collection
PPT
Mule esb api layer
PPT
Mule google connectors
PPT
Mule security
PPTX
Scatter gather flow in mule
PPTX
Mule rabbitmq
PPTX
Mule drools
PPTX
Mule esb DataWeave
PPTX
Idempotent filter in mule
Mule execution
Mule esb stripe
Dataweave
Mule for each scope header collection
Mule esb api layer
Mule google connectors
Mule security
Scatter gather flow in mule
Mule rabbitmq
Mule drools
Mule esb DataWeave
Idempotent filter in mule

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
cuic standard and advanced reporting.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Empathic Computing: Creating Shared Understanding
PDF
Electronic commerce courselecture one. Pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Modernizing your data center with Dell and AMD
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
Big Data Technologies - Introduction.pptx
The AUB Centre for AI in Media Proposal.docx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation_ Review paper, used for researhc scholars
The Rise and Fall of 3GPP – Time for a Sabbatical?
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
cuic standard and advanced reporting.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Empathic Computing: Creating Shared Understanding
Electronic commerce courselecture one. Pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Digital-Transformation-Roadmap-for-Companies.pptx
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Weekly Chronicles - August'25 Week I
Mobile App Security Testing_ A Comprehensive Guide.pdf
Modernizing your data center with Dell and AMD
Building Integrated photovoltaic BIPV_UPV.pdf
Understanding_Digital_Forensics_Presentation.pptx

Groovy in Mule

  • 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