SlideShare a Scribd company logo
Using Groovy Component
- By Rahul Kumar
Groovy
The Groovy Component is handy when you’re modernizing legacy systems, as
you can simply throw the old lines of code into a component instead of having
to reengineer the code’s behavior through a series of different Mule
components (this is not ideal from a debugging and maintenance perspective,
though).
Groovy also allows the developer to configure interceptors and alter the values
or references of particular properties in a script. Interceptors are configured to
provide additional services to a message as it flows through a component
Groovy
Script Text: Type the script that the component will load directly into this
space.
Script File: Enter the location of the script to be loaded by the component.
The file can reside on the classpath or the local file system.
Bean Reference: Lets you add a Java bean, which encapsulates multiple
objects into a single bean. The Script component can then store and reuse
the bean when applicable.
Examples
<flow name="groovyTransformerWithParameters">
<script:transformer name="stringReplaceWithParams">
<script:script engine="groovy">
<property key="oldStr" value="l" />
<property key="newStr" value="x" />
<script:text>
return payload.toString().replaceAll("$oldStr", "$newStr")
</script:text> </script:script>
</script:transformer> </flow>
This example demonstrates simple string replacement.
Examples
<<scripting:component doc:name="Script">
<scripting:script engine="Groovy"><![CDATA[
throw new IllegalArgumentException('bad arg')
]]></scripting:script>
</scripting:component>
This example demonstrates throwing Exception with Groovy
Examples
<<scripting:component doc:name="Script">
<scripting:script engine="Groovy"><![CDATA[
Thread.sleep(60000)
]]></scripting:script>
</scripting:component>
This example demonstrates how to use Groovy to make the Thread sleep for 1 munute.
Thank You !!

More Related Content

What's hot (17)

PDF
MuleSoft ESB Message Enricher
akashdprajapati
 
PPTX
Splitting with mule part2
Anirban Sen Chowdhary
 
PPTX
Xslt with mule
Son Nguyen
 
PPTX
Encrypting/Decrypting mule
Anirban Sen Chowdhary
 
PPTX
For each component in mule
Rajkattamuri
 
PPTX
xslt in mule
Praneethchampion
 
PPTX
How to get http query parameters in mule
Ramakrishna kapa
 
PPTX
Mule new jdbc component
Anirban Sen Chowdhary
 
PPTX
Runing batch job in mule
Son Nguyen
 
PPTX
Mulesoft file connector
kumar gaurav
 
PPTX
Message processor in mule
Son Nguyen
 
PPTX
Groovy example in mule
Mohammed246
 
PPTX
How to use processor chain
sivachandra mandalapu
 
PPT
Mule introduction
Satya Sekhar Das Mandal
 
PPTX
Mule esb
Khan625
 
PPTX
Mule system properties
Ravinder Singh
 
PPTX
Mule esb transformers
Mani Rathnam Gudi
 
MuleSoft ESB Message Enricher
akashdprajapati
 
Splitting with mule part2
Anirban Sen Chowdhary
 
Xslt with mule
Son Nguyen
 
Encrypting/Decrypting mule
Anirban Sen Chowdhary
 
For each component in mule
Rajkattamuri
 
xslt in mule
Praneethchampion
 
How to get http query parameters in mule
Ramakrishna kapa
 
Mule new jdbc component
Anirban Sen Chowdhary
 
Runing batch job in mule
Son Nguyen
 
Mulesoft file connector
kumar gaurav
 
Message processor in mule
Son Nguyen
 
Groovy example in mule
Mohammed246
 
How to use processor chain
sivachandra mandalapu
 
Mule introduction
Satya Sekhar Das Mandal
 
Mule esb
Khan625
 
Mule system properties
Ravinder Singh
 
Mule esb transformers
Mani Rathnam Gudi
 

Viewers also liked (16)

PPTX
Mulesoft Using Groovy Component
kumar gaurav
 
PPTX
Mule Groovy component
Ankush Sharma
 
PPTX
Mule groovy
Sindhu VL
 
PPTX
Accessing Mule variables in groovy
Anirban Sen Chowdhary
 
PPTX
Accessing jms in mule using groovy
Anirban Sen Chowdhary
 
PPTX
Groovy demo
Ramakrishna kapa
 
PPTX
Groovy with Mule
irfan1008
 
PPTX
Choice router mule
Sindhu VL
 
PPTX
Cloud hub with mule
Son Nguyen
 
PPTX
Mule property placeholder
Sashidhar Rao GDS
 
PPTX
Message enricher in mule
Sashidhar Rao GDS
 
PPTX
Process file one after another
Anirban Sen Chowdhary
 
PPTX
Using groovy in mule
Son Nguyen
 
PDF
Mule esb examples
Sashidhar Rao GDS
 
PPTX
Mule message enricher
Anirban Sen Chowdhary
 
PPTX
Simple groovy example in mule
Anirban Sen Chowdhary
 
Mulesoft Using Groovy Component
kumar gaurav
 
Mule Groovy component
Ankush Sharma
 
Mule groovy
Sindhu VL
 
Accessing Mule variables in groovy
Anirban Sen Chowdhary
 
Accessing jms in mule using groovy
Anirban Sen Chowdhary
 
Groovy demo
Ramakrishna kapa
 
Groovy with Mule
irfan1008
 
Choice router mule
Sindhu VL
 
Cloud hub with mule
Son Nguyen
 
Mule property placeholder
Sashidhar Rao GDS
 
Message enricher in mule
Sashidhar Rao GDS
 
Process file one after another
Anirban Sen Chowdhary
 
Using groovy in mule
Son Nguyen
 
Mule esb examples
Sashidhar Rao GDS
 
Mule message enricher
Anirban Sen Chowdhary
 
Simple groovy example in mule
Anirban Sen Chowdhary
 
Ad

More from Rahul Kumar (20)

PPTX
Combine collections transformer
Rahul Kumar
 
PPTX
Creating global functions
Rahul Kumar
 
PPTX
Creating custom object store
Rahul Kumar
 
PPTX
Using expression component
Rahul Kumar
 
PPTX
Creating custom transformer
Rahul Kumar
 
PPTX
Creating custom aggregation strategy
Rahul Kumar
 
PPTX
Creating custom aggregator
Rahul Kumar
 
PPTX
Byte array to hex string transformer
Rahul Kumar
 
PPTX
Creating custom filter
Rahul Kumar
 
PPTX
Hex string to byte array transformer
Rahul Kumar
 
PPTX
XML to DOM Transformer
Rahul Kumar
 
PPTX
Dom to xml transformer
Rahul Kumar
 
PPTX
Object to input stream transformer
Rahul Kumar
 
PPTX
Byte array to object transformer
Rahul Kumar
 
PPTX
Byte array to string transformer
Rahul Kumar
 
PPTX
Object to string transformer
Rahul Kumar
 
PPTX
Csv to json transform in simple steps
Rahul Kumar
 
PPTX
Using scatter gather
Rahul Kumar
 
PPTX
Choice router
Rahul Kumar
 
PPTX
Using idempotent filter
Rahul Kumar
 
Combine collections transformer
Rahul Kumar
 
Creating global functions
Rahul Kumar
 
Creating custom object store
Rahul Kumar
 
Using expression component
Rahul Kumar
 
Creating custom transformer
Rahul Kumar
 
Creating custom aggregation strategy
Rahul Kumar
 
Creating custom aggregator
Rahul Kumar
 
Byte array to hex string transformer
Rahul Kumar
 
Creating custom filter
Rahul Kumar
 
Hex string to byte array transformer
Rahul Kumar
 
XML to DOM Transformer
Rahul Kumar
 
Dom to xml transformer
Rahul Kumar
 
Object to input stream transformer
Rahul Kumar
 
Byte array to object transformer
Rahul Kumar
 
Byte array to string transformer
Rahul Kumar
 
Object to string transformer
Rahul Kumar
 
Csv to json transform in simple steps
Rahul Kumar
 
Using scatter gather
Rahul Kumar
 
Choice router
Rahul Kumar
 
Using idempotent filter
Rahul Kumar
 
Ad

Recently uploaded (20)

PPTX
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PDF
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
PDF
Executive Business Intelligence Dashboards
vandeslie24
 
PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PPTX
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
PPTX
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PPTX
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Engineering the Java Web Application (MVC)
abhishekoza1981
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PPTX
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
Executive Business Intelligence Dashboards
vandeslie24
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Engineering the Java Web Application (MVC)
abhishekoza1981
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 

Using groovy component