O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Próximos SlideShares
Simple groovy example in mule
Simple groovy example in mule
Carregando em…3
×

Confira estes a seguir

1 de 13 Anúncio

Mais Conteúdo rRelacionado

Quem viu também gostou (20)

Anúncio

Semelhante a Groovy in Mule (20)

Anúncio

Mais recentes (20)

Groovy in Mule

  1. 1. Simple Groovy example in Mule
  2. 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. 3. But how can we use Sleep method in Mule?? .
  4. 4. Here I will show you how ……
  5. 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. 6. Yes .. We can do it by using sleep method in our flow
  7. 7. So, we need Groovy component to implement sleep method:-
  8. 8. So our Mule flow will be now following :- This Groovy component will be holding the payload for some time
  9. 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. 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. 11. And we will get the file in our outbound location E:backuptestnewfolder after 3000 ms
  12. 12. Hope you enjoyed the simple yet an amazing trick in Mule

×