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

More Related Content

PPTX
Mulesoft Using Groovy Component
PPTX
Mule Esb Data Weave
PPTX
Encrypting/Decrypting mule
PPTX
Simple groovy example in mule
PPTX
Quartz component in mule demo
PPTX
Mule esb :Data Weave
PPTX
Compress and decompress
PPTX
Quartz component in mule
Mulesoft Using Groovy Component
Mule Esb Data Weave
Encrypting/Decrypting mule
Simple groovy example in mule
Quartz component in mule demo
Mule esb :Data Weave
Compress and decompress
Quartz component in mule

What's hot (14)

PPTX
Caching and invalidating with managed store
PPTX
Mule esb add logger to existing flow
PPTX
Compressing & decompressing in mule
PPTX
Mule jdbc
PPTX
Junit in mule demo
PPTX
For each component in mule
PPTX
Stored procedure in Mule
PPTX
Caching & validating
PDF
MuleSoft ESB Message Enricher
PPTX
Accessing Mule variables in groovy
ODP
Mule ESB SMTP Connector Integration
PPTX
Groovy in Mule
PPTX
Mule esb
PPTX
Message properties component in Mule
Caching and invalidating with managed store
Mule esb add logger to existing flow
Compressing & decompressing in mule
Mule jdbc
Junit in mule demo
For each component in mule
Stored procedure in Mule
Caching & validating
MuleSoft ESB Message Enricher
Accessing Mule variables in groovy
Mule ESB SMTP Connector Integration
Groovy in Mule
Mule esb
Message properties component in Mule
Ad

Viewers also liked (13)

PPTX
DFSO TERCER PARCIAL 3D
PDF
Boletín de novidades. Sección adultos. Novembro-decembro 2016
PDF
Wood_Design_Details (1)
PPTX
Rest fullservices
PPTX
Senior Project
PPTX
Maven tools & archetypes
PDF
Une Spain Latam les desea Felices Fiestas
PDF
Taller Comparativo y Diseño de una Política de Seguridad de la Información
PDF
Informe Clima de Negocios LATAM 2015
PPTX
Funções do 1º e 2º grau
PDF
今からでも大丈夫!Firebase入門
PDF
Natural Language Processing: L02 words
DFSO TERCER PARCIAL 3D
Boletín de novidades. Sección adultos. Novembro-decembro 2016
Wood_Design_Details (1)
Rest fullservices
Senior Project
Maven tools & archetypes
Une Spain Latam les desea Felices Fiestas
Taller Comparativo y Diseño de una Política de Seguridad de la Información
Informe Clima de Negocios LATAM 2015
Funções do 1º e 2º grau
今からでも大丈夫!Firebase入門
Natural Language Processing: L02 words
Ad

Similar to Groovy example in mule (20)

PPTX
Holding a mule flow
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 example in mule
PPTX
Groovy with Mule
PPTX
SmpleGroovyexampleinmule
PPTX
Handle File on mule
PPT
Dance for the puppet master: G6 Tech Talk
PPTX
Ufo Ship for AWS ECS
ODP
Apache Syncope: an Apache Camel Integration Proposal
PDF
Netty - anfix tech&beers
PPTX
Everything you wanted to know about writing async, concurrent http apps in java
PDF
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
PPTX
Adding dynamic file
PPTX
Puppet - an introduction
PDF
Thotcon - All aboard the Fail Whale
PPTX
Process file one after another
Holding a mule flow
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 example in mule
Groovy with Mule
SmpleGroovyexampleinmule
Handle File on mule
Dance for the puppet master: G6 Tech Talk
Ufo Ship for AWS ECS
Apache Syncope: an Apache Camel Integration Proposal
Netty - anfix tech&beers
Everything you wanted to know about writing async, concurrent http apps in java
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Adding dynamic file
Puppet - an introduction
Thotcon - All aboard the Fail Whale
Process file one after another

More from Mohammed246 (20)

PPTX
Expression filter in Mule
PPT
Anypoint data gateway
PPT
Oracle connector
PPT
Api Layer
PPTX
Maven part 3
PPTX
Maven part 2
PPTX
Maven part 1
PPTX
Jenkins part 3
PPTX
Jenkins part 2
PPTX
Jenkins Part 1
PPTX
jBPM Connector
PPTX
Java for beginners
PPTX
Scatter gather
PPTX
Velocity in Mule
PPTX
Rabbit Mq in Mule
PPTX
Quartz in Mule
PPTX
Simple web service vm
PPTX
Validate soap request in mule
PPTX
Web service vm in mule
PPTX
Xslt in mule
Expression filter in Mule
Anypoint data gateway
Oracle connector
Api Layer
Maven part 3
Maven part 2
Maven part 1
Jenkins part 3
Jenkins part 2
Jenkins Part 1
jBPM Connector
Java for beginners
Scatter gather
Velocity in Mule
Rabbit Mq in Mule
Quartz in Mule
Simple web service vm
Validate soap request in mule
Web service vm in mule
Xslt in mule

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Spectroscopy.pptx food analysis technology
PDF
Electronic commerce courselecture one. Pdf
PPTX
Cloud computing and distributed systems.
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
cuic standard and advanced reporting.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Reach Out and Touch Someone: Haptics and Empathic Computing
Building Integrated photovoltaic BIPV_UPV.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Network Security Unit 5.pdf for BCA BBA.
Chapter 3 Spatial Domain Image Processing.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Mobile App Security Testing_ A Comprehensive Guide.pdf
The AUB Centre for AI in Media Proposal.docx
Advanced methodologies resolving dimensionality complications for autism neur...
MYSQL Presentation for SQL database connectivity
Spectroscopy.pptx food analysis technology
Electronic commerce courselecture one. Pdf
Cloud computing and distributed systems.
NewMind AI Weekly Chronicles - August'25 Week I
“AI and Expert System Decision Support & Business Intelligence Systems”
cuic standard and advanced reporting.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf

Groovy example in mule

  • 3. .
  • 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