SlideShare une entreprise Scribd logo
1  sur  13
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
Simple groovy example in mule

Contenu connexe

Tendances (12)

Initialize database in Mule part2
Initialize database in Mule part2Initialize database in Mule part2
Initialize database in Mule part2
 
Spicing your mule response
Spicing your mule responseSpicing your mule response
Spicing your mule response
 
Accessing jms in mule using groovy
Accessing jms in mule using groovyAccessing jms in mule using groovy
Accessing jms in mule using groovy
 
Accessing Mule variables in groovy
Accessing Mule variables in groovyAccessing Mule variables in groovy
Accessing Mule variables in groovy
 
Mule soap
Mule soapMule soap
Mule soap
 
Groovy in Mule
Groovy in MuleGroovy in Mule
Groovy in Mule
 
Mulesoft Using Groovy Component
Mulesoft Using Groovy ComponentMulesoft Using Groovy Component
Mulesoft Using Groovy Component
 
Scatter and gather in mule
Scatter and gather in muleScatter and gather in mule
Scatter and gather in mule
 
Mule quartz
Mule quartz Mule quartz
Mule quartz
 
Using groovy in mule
Using groovy in muleUsing groovy in mule
Using groovy in mule
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 

En vedette

CV-BUDI AHSAN-btmVwcolor
CV-BUDI AHSAN-btmVwcolorCV-BUDI AHSAN-btmVwcolor
CV-BUDI AHSAN-btmVwcolor
Ahsan Budi
 
Placas tectonicas principales por Mayra Chadán UCE
Placas tectonicas principales por Mayra Chadán UCEPlacas tectonicas principales por Mayra Chadán UCE
Placas tectonicas principales por Mayra Chadán UCE
mayrachadan
 

En vedette (18)

CV-BUDI AHSAN-btmVwcolor
CV-BUDI AHSAN-btmVwcolorCV-BUDI AHSAN-btmVwcolor
CV-BUDI AHSAN-btmVwcolor
 
Pp2 p3 -mas informacion - luisa henriquez- the future of the archtecture i...
Pp2   p3 -mas informacion - luisa henriquez-  the future of the archtecture i...Pp2   p3 -mas informacion - luisa henriquez-  the future of the archtecture i...
Pp2 p3 -mas informacion - luisa henriquez- the future of the archtecture i...
 
FARYDA LEDERWAREN Plan
FARYDA LEDERWAREN PlanFARYDA LEDERWAREN Plan
FARYDA LEDERWAREN Plan
 
Eloop
EloopEloop
Eloop
 
Siete maravillas del mundo Mayra Chadán
Siete maravillas del mundo Mayra ChadánSiete maravillas del mundo Mayra Chadán
Siete maravillas del mundo Mayra Chadán
 
Nube de palabras
Nube de palabrasNube de palabras
Nube de palabras
 
Rúbrica para exponer con recursos visuales
Rúbrica para exponer con recursos visualesRúbrica para exponer con recursos visuales
Rúbrica para exponer con recursos visuales
 
Munaroh
MunarohMunaroh
Munaroh
 
Fichaje
FichajeFichaje
Fichaje
 
Los tulises de matamoros
Los tulises de matamorosLos tulises de matamoros
Los tulises de matamoros
 
Análisis del libro para el maestro y el libro para el alumno
Análisis del libro para el maestro y el libro para el alumnoAnálisis del libro para el maestro y el libro para el alumno
Análisis del libro para el maestro y el libro para el alumno
 
Ensayo valores
Ensayo valoresEnsayo valores
Ensayo valores
 
Trabajo manual de obra
Trabajo manual de obraTrabajo manual de obra
Trabajo manual de obra
 
Placas tectonicas principales por Mayra Chadán UCE
Placas tectonicas principales por Mayra Chadán UCEPlacas tectonicas principales por Mayra Chadán UCE
Placas tectonicas principales por Mayra Chadán UCE
 
Java Core. Lecture# 1. Intro
Java Core. Lecture# 1. IntroJava Core. Lecture# 1. Intro
Java Core. Lecture# 1. Intro
 
El país de las hojas sueltas. tomo i. desde la época prehispánica hasta el fi...
El país de las hojas sueltas. tomo i. desde la época prehispánica hasta el fi...El país de las hojas sueltas. tomo i. desde la época prehispánica hasta el fi...
El país de las hojas sueltas. tomo i. desde la época prehispánica hasta el fi...
 
Tabla periodica
Tabla periodicaTabla periodica
Tabla periodica
 
Microprocesadores
MicroprocesadoresMicroprocesadores
Microprocesadores
 

Similaire à Simple groovy example in mule

Similaire à Simple groovy example in mule (20)

SmpleGroovyexampleinmule
SmpleGroovyexampleinmuleSmpleGroovyexampleinmule
SmpleGroovyexampleinmule
 
Groovy example in mule
Groovy example in muleGroovy example in mule
Groovy example in mule
 
Groovy with mule
Groovy with muleGroovy with mule
Groovy with mule
 
Groovy with mule
Groovy with muleGroovy with mule
Groovy with mule
 
Simple groovy example in mule
Simple groovy example in muleSimple groovy example in mule
Simple groovy example in mule
 
Holding a mule flow
Holding a mule flowHolding a mule flow
Holding a mule flow
 
Handle File on mule
Handle File on muleHandle File on mule
Handle File on mule
 
Schedule and monitor in mule
Schedule and monitor in muleSchedule and monitor in mule
Schedule and monitor in mule
 
Using spring scheduler mule
Using spring scheduler muleUsing spring scheduler mule
Using spring scheduler mule
 
Scheduling and monitoring with java in mule
Scheduling and monitoring with java in muleScheduling and monitoring with java in mule
Scheduling and monitoring with java in mule
 
Using spring task scheduler in java in mule
Using spring task scheduler in java in muleUsing spring task scheduler in java in mule
Using spring task scheduler in java in mule
 
Mule with stored procedure
Mule with stored procedureMule with stored procedure
Mule with stored procedure
 
Mule stored procedure
Mule stored procedureMule stored procedure
Mule stored procedure
 
Mule with stored procedure
Mule with stored procedureMule with stored procedure
Mule with stored procedure
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 
Cache for community edition
Cache for community edition Cache for community edition
Cache for community edition
 
Community edition Cache
Community edition CacheCommunity edition Cache
Community edition Cache
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 

Plus de Mohammed625 (15)

Mule with drools
Mule with drools Mule with drools
Mule with drools
 
Creating dynamic json
Creating dynamic json Creating dynamic json
Creating dynamic json
 
Webservice with vm in mule
Webservice with vm in mule Webservice with vm in mule
Webservice with vm in mule
 
Deploying and running in mule standalone
Deploying and running in mule standaloneDeploying and running in mule standalone
Deploying and running in mule standalone
 
Mule real world old
Mule real world oldMule real world old
Mule real world old
 
Mule esb introduction
Mule esb introductionMule esb introduction
Mule esb introduction
 
Mule overview
Mule overviewMule overview
Mule overview
 
Mule technology
Mule technologyMule technology
Mule technology
 
Presentation
PresentationPresentation
Presentation
 
Scatter gather in mule
Scatter gather in muleScatter gather in mule
Scatter gather in mule
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
Java multithreading
Java multithreadingJava multithreading
Java multithreading
 
WebServices using Soap
WebServices using SoapWebServices using Soap
WebServices using Soap
 
Sunstate
SunstateSunstate
Sunstate
 
MuleEsb
MuleEsbMuleEsb
MuleEsb
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 

Simple groovy example 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