SlideShare a Scribd company logo
Mule Concepts
Mule Expression Language (MEL)
Basics -V
• Payload and Attachments
– To copy the current payload in a flow variable
named originalPayload then restore it :
<set-variable variableName="originalPayload"
value="#[message.payload]" /> <set-payload value="#[originalPayload]"
/>
– To retrieve the message payload in a particular format, using Mule’s
auto-transformation capability, use payloadAs:
<logger message="#[message.payloadAs(java.lang.String)]" />
– To extract all .txt and .xml attachments, use a filtered projection:
<expression-transformer expression="#[($.value in
message.inboundAttachments.entrySet() if $.key ~=
'(.*.txt|.*.xml)')]" />
– To ask for a null payload:
#[payload is NullPayload]
Mule Expression Language (MEL)
• Regex Support
– Regular expression helper functions retrieve null, a single value or an
array of values, depending on matches.
– The forms that take a melExpression argument apply the regex to the
result of its evaluation instead of message.payload.
#[regex(regularExpression [, melExpression [, matchFlags]])]
– Example :
• to select all the lines of the payload that begin with To:, From:, or Cc: use:
#[regex('^(To|From|Cc):')]
Mule Expression Language (MEL)
• XPath Support
– XPath helper functions return DOM4J nodes.
– By default the XPath expression is evaluated
onmessage.payload unless an xmlElement is specified:
#[xpath3(xPathExpression [, xmlElement])]
– To get the text content of an element or an attribute:
#[xpath3('//title').text]
#[xpath3('//title/@id').value]
Mule Expression Language (MEL)
• JSON Processing
– MEL has no direct support for JSON.
– The json-to-object-transformer can turn a JSON payload into a
hierarchy of simple data structures that are easily parsed with MEL.
– For the equivalent of this JSON path expression:
$..[? (@.title=='Moby Dick')].price
The following uses a filtered projection:
<json:json-to-object-transformer returnClass="java.lang.Object" />
<expression-transformer expression='#[($.price in message.payload if
$.title =='Moby Dick')[0]]" />
Mule Expression Language (MEL)
• Including DataWeave code
– You can carry out powerful complex data transformations by
including MEL DataWeave Functionsthat use DataWeave Language
code.
– You can include this code via two different functions in MEL: 'dw()' and
'split()'.
– 'dw' simply executes the DataWeave code you pass as an argument
and returns the transformation’s result
– 'split()' executes the code you pass as an argument and returns an
iterator that allows you to process each instance of the output as a
separate message.
dw("myobject:{id:payload.accountid, user:payload.user}")
Mule Expression Language (MEL)
• Miscellaneous Operations
– Assign to variable lastname the value of the message
inbound property lastname:
#[lastname = message.inboundProperties.lastname]
– Append a string to the message payload:
#[message.payload + 'mystring']
– Call a static method:
#[java.net.URLEncoder.encode()]
– Create a hash map:
#[new java.util.HashMap()]
Mule Expression Language (MEL)

More Related Content

What's hot

Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mule
Anirban Sen Chowdhary
 
Integrate with database by groovy
Integrate with database by groovyIntegrate with database by groovy
Integrate with database by groovy
Son Nguyen
 
Passing java arrays in oracle stored procedure from mule esb flow
Passing java arrays in oracle stored procedure from mule esb flowPassing java arrays in oracle stored procedure from mule esb flow
Passing java arrays in oracle stored procedure from mule esb flow
Priyobroto Ghosh (Mule ESB Certified)
 
Component bindings in mule
Component bindings in muleComponent bindings in mule
Component bindings in mule
Sindhu VL
 
Mule expression component
Mule expression componentMule expression component
Mule expression component
Karnam Karthik
 
MuleSoft Nashik Virtual Meetup#3 - Deep Dive Into DataWeave and its Module
MuleSoft Nashik Virtual  Meetup#3 - Deep Dive Into DataWeave and its ModuleMuleSoft Nashik Virtual  Meetup#3 - Deep Dive Into DataWeave and its Module
MuleSoft Nashik Virtual Meetup#3 - Deep Dive Into DataWeave and its Module
Jitendra Bafna
 
Mule xml transformation
Mule xml transformationMule xml transformation
Mule xml transformation
D.Rajesh Kumar
 
Stored Procedure With In Out Parameters in Mule 3.6
 Stored Procedure With In Out Parameters in Mule 3.6 Stored Procedure With In Out Parameters in Mule 3.6
Stored Procedure With In Out Parameters in Mule 3.6
Sashidhar Rao GDS
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo
javeed_mhd
 
Message properties component in Mule
Message properties component in MuleMessage properties component in Mule
Message properties component in Mule
Khan625
 
Mule jdbc
Mule   jdbcMule   jdbc
Mule jdbc
KalaimathiS
 
MuleSoft ESB scatter-gather and base64
MuleSoft ESB scatter-gather and base64MuleSoft ESB scatter-gather and base64
MuleSoft ESB scatter-gather and base64
akashdprajapati
 
MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher
akashdprajapati
 
Mule database connector
Mule database connectorMule database connector
Mule database connector
Ankush Sharma
 
Data weave documentation
Data weave documentationData weave documentation
Data weave documentation
Sindhu VL
 
Mule properties
Mule propertiesMule properties
Mule properties
Ravinder Singh
 
Mule Esb Data Weave
Mule Esb Data WeaveMule Esb Data Weave
Mule Esb Data Weave
Mohammed246
 
Refreshing mule cache using oracle database change notification
Refreshing mule cache using oracle database change notificationRefreshing mule cache using oracle database change notification
Refreshing mule cache using oracle database change notification
Priyobroto Ghosh (Mule ESB Certified)
 
Introduction to dataweave
Introduction to dataweaveIntroduction to dataweave
Introduction to dataweave
Swati Deshpande
 
Mule esb :Data Weave
Mule esb :Data WeaveMule esb :Data Weave
Mule esb :Data Weave
AnilKumar Etagowni
 

What's hot (20)

Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mule
 
Integrate with database by groovy
Integrate with database by groovyIntegrate with database by groovy
Integrate with database by groovy
 
Passing java arrays in oracle stored procedure from mule esb flow
Passing java arrays in oracle stored procedure from mule esb flowPassing java arrays in oracle stored procedure from mule esb flow
Passing java arrays in oracle stored procedure from mule esb flow
 
Component bindings in mule
Component bindings in muleComponent bindings in mule
Component bindings in mule
 
Mule expression component
Mule expression componentMule expression component
Mule expression component
 
MuleSoft Nashik Virtual Meetup#3 - Deep Dive Into DataWeave and its Module
MuleSoft Nashik Virtual  Meetup#3 - Deep Dive Into DataWeave and its ModuleMuleSoft Nashik Virtual  Meetup#3 - Deep Dive Into DataWeave and its Module
MuleSoft Nashik Virtual Meetup#3 - Deep Dive Into DataWeave and its Module
 
Mule xml transformation
Mule xml transformationMule xml transformation
Mule xml transformation
 
Stored Procedure With In Out Parameters in Mule 3.6
 Stored Procedure With In Out Parameters in Mule 3.6 Stored Procedure With In Out Parameters in Mule 3.6
Stored Procedure With In Out Parameters in Mule 3.6
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo
 
Message properties component in Mule
Message properties component in MuleMessage properties component in Mule
Message properties component in Mule
 
Mule jdbc
Mule   jdbcMule   jdbc
Mule jdbc
 
MuleSoft ESB scatter-gather and base64
MuleSoft ESB scatter-gather and base64MuleSoft ESB scatter-gather and base64
MuleSoft ESB scatter-gather and base64
 
MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher
 
Mule database connector
Mule database connectorMule database connector
Mule database connector
 
Data weave documentation
Data weave documentationData weave documentation
Data weave documentation
 
Mule properties
Mule propertiesMule properties
Mule properties
 
Mule Esb Data Weave
Mule Esb Data WeaveMule Esb Data Weave
Mule Esb Data Weave
 
Refreshing mule cache using oracle database change notification
Refreshing mule cache using oracle database change notificationRefreshing mule cache using oracle database change notification
Refreshing mule cache using oracle database change notification
 
Introduction to dataweave
Introduction to dataweaveIntroduction to dataweave
Introduction to dataweave
 
Mule esb :Data Weave
Mule esb :Data WeaveMule esb :Data Weave
Mule esb :Data Weave
 

Similar to Mule mel 5_tips

Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200
harika thamishetti
 
How to – data integrity checks in batch processing
How to – data integrity checks in batch processingHow to – data integrity checks in batch processing
How to – data integrity checks in batch processing
Son Nguyen
 
Mule jdbc
Mule   jdbcMule   jdbc
MuleSoft ESB Object Store
MuleSoft ESB Object StoreMuleSoft ESB Object Store
MuleSoft ESB Object Store
akashdprajapati
 
Data weave (MuleSoft)
Data weave (MuleSoft)Data weave (MuleSoft)
Data weave (MuleSoft)
Nandu List5
 
MuleSoft DataWeave data transformation language
MuleSoft DataWeave data transformation languageMuleSoft DataWeave data transformation language
MuleSoft DataWeave data transformation language
fganora
 
Introduction of ssis
Introduction of ssisIntroduction of ssis
Introduction of ssisdeepakk073
 
Mule connectors-part 1
Mule connectors-part 1Mule connectors-part 1
Mule connectors-part 1
VirtusaPolaris
 
Mule connectors-session1
Mule connectors-session1Mule connectors-session1
Mule connectors-session1
Vishnukanth Rachineni
 
Mule esb
Mule esbMule esb
Mule esb
sathyaraj Anand
 
EPiServer report generation
EPiServer report generationEPiServer report generation
EPiServer report generation
Paul Graham
 
Parameters as a part of body
Parameters as a part of bodyParameters as a part of body
Parameters as a part of body
Anirban Sen Chowdhary
 
Modular javascript
Modular javascriptModular javascript
Modular javascriptZain Shaikh
 
SSIS Project Profile
SSIS Project ProfileSSIS Project Profile
SSIS Project Profiletthompson0421
 
Mule esb
Mule esbMule esb
Mule esb
javeed_mhd
 
Mule esb DataWeave
Mule esb DataWeaveMule esb DataWeave
Mule esb DataWeave
Praneethchampion
 
Mule esb Data Weave
Mule esb Data WeaveMule esb Data Weave
Mule esb Data Weave
F K
 
Mule esb dataweave
Mule esb dataweaveMule esb dataweave
Mule esb dataweave
Rajkattamuri
 
Mule esb
Mule esbMule esb
Mule esb
Sunil Komarapu
 
Mule esb
Mule esbMule esb
Mule esb
Hasan Syed
 

Similar to Mule mel 5_tips (20)

Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200
 
How to – data integrity checks in batch processing
How to – data integrity checks in batch processingHow to – data integrity checks in batch processing
How to – data integrity checks in batch processing
 
Mule jdbc
Mule   jdbcMule   jdbc
Mule jdbc
 
MuleSoft ESB Object Store
MuleSoft ESB Object StoreMuleSoft ESB Object Store
MuleSoft ESB Object Store
 
Data weave (MuleSoft)
Data weave (MuleSoft)Data weave (MuleSoft)
Data weave (MuleSoft)
 
MuleSoft DataWeave data transformation language
MuleSoft DataWeave data transformation languageMuleSoft DataWeave data transformation language
MuleSoft DataWeave data transformation language
 
Introduction of ssis
Introduction of ssisIntroduction of ssis
Introduction of ssis
 
Mule connectors-part 1
Mule connectors-part 1Mule connectors-part 1
Mule connectors-part 1
 
Mule connectors-session1
Mule connectors-session1Mule connectors-session1
Mule connectors-session1
 
Mule esb
Mule esbMule esb
Mule esb
 
EPiServer report generation
EPiServer report generationEPiServer report generation
EPiServer report generation
 
Parameters as a part of body
Parameters as a part of bodyParameters as a part of body
Parameters as a part of body
 
Modular javascript
Modular javascriptModular javascript
Modular javascript
 
SSIS Project Profile
SSIS Project ProfileSSIS Project Profile
SSIS Project Profile
 
Mule esb
Mule esbMule esb
Mule esb
 
Mule esb DataWeave
Mule esb DataWeaveMule esb DataWeave
Mule esb DataWeave
 
Mule esb Data Weave
Mule esb Data WeaveMule esb Data Weave
Mule esb Data Weave
 
Mule esb dataweave
Mule esb dataweaveMule esb dataweave
Mule esb dataweave
 
Mule esb
Mule esbMule esb
Mule esb
 
Mule esb
Mule esbMule esb
Mule esb
 

More from kunal vishe

Mule data weave_7
Mule data weave_7Mule data weave_7
Mule data weave_7
kunal vishe
 
Mule data weave_8
Mule data weave_8Mule data weave_8
Mule data weave_8
kunal vishe
 
Mule data weave_4
Mule data weave_4Mule data weave_4
Mule data weave_4
kunal vishe
 
Mule mel 4_tips
Mule mel 4_tipsMule mel 4_tips
Mule mel 4_tips
kunal vishe
 
Mule mel 3
Mule mel 3Mule mel 3
Mule mel 3
kunal vishe
 
Mule mel 2
Mule mel 2Mule mel 2
Mule mel 2
kunal vishe
 
Mule mel 1
Mule mel 1Mule mel 1
Mule mel 1
kunal vishe
 
Mule scopes request_response_scope
Mule scopes request_response_scopeMule scopes request_response_scope
Mule scopes request_response_scope
kunal vishe
 
Mule scopes foreach_scope
Mule scopes foreach_scopeMule scopes foreach_scope
Mule scopes foreach_scope
kunal vishe
 
Mule scopes async_scope
Mule scopes async_scopeMule scopes async_scope
Mule scopes async_scope
kunal vishe
 
Mule scopes 2
Mule scopes 2Mule scopes 2
Mule scopes 2
kunal vishe
 
Mule scopes 1
Mule scopes 1Mule scopes 1
Mule scopes 1
kunal vishe
 
Mule debugging logging_configuration_in_mule
Mule debugging logging_configuration_in_muleMule debugging logging_configuration_in_mule
Mule debugging logging_configuration_in_mule
kunal vishe
 
Mule debugging logging_in_mule
Mule debugging logging_in_muleMule debugging logging_in_mule
Mule debugging logging_in_mule
kunal vishe
 
Mule debugging managing_stack_traces
Mule debugging managing_stack_tracesMule debugging managing_stack_traces
Mule debugging managing_stack_traces
kunal vishe
 
Mule error handling_rollback exception strategy
Mule error handling_rollback exception strategyMule error handling_rollback exception strategy
Mule error handling_rollback exception strategy
kunal vishe
 
Mule message
Mule messageMule message
Mule message
kunal vishe
 
Mule error handling_choice exception strategy
Mule error handling_choice exception strategyMule error handling_choice exception strategy
Mule error handling_choice exception strategy
kunal vishe
 
Mule concepts exception strategies
Mule concepts exception strategiesMule concepts exception strategies
Mule concepts exception strategies
kunal vishe
 
Mule concepts filters scopes_routers
Mule concepts filters scopes_routersMule concepts filters scopes_routers
Mule concepts filters scopes_routers
kunal vishe
 

More from kunal vishe (20)

Mule data weave_7
Mule data weave_7Mule data weave_7
Mule data weave_7
 
Mule data weave_8
Mule data weave_8Mule data weave_8
Mule data weave_8
 
Mule data weave_4
Mule data weave_4Mule data weave_4
Mule data weave_4
 
Mule mel 4_tips
Mule mel 4_tipsMule mel 4_tips
Mule mel 4_tips
 
Mule mel 3
Mule mel 3Mule mel 3
Mule mel 3
 
Mule mel 2
Mule mel 2Mule mel 2
Mule mel 2
 
Mule mel 1
Mule mel 1Mule mel 1
Mule mel 1
 
Mule scopes request_response_scope
Mule scopes request_response_scopeMule scopes request_response_scope
Mule scopes request_response_scope
 
Mule scopes foreach_scope
Mule scopes foreach_scopeMule scopes foreach_scope
Mule scopes foreach_scope
 
Mule scopes async_scope
Mule scopes async_scopeMule scopes async_scope
Mule scopes async_scope
 
Mule scopes 2
Mule scopes 2Mule scopes 2
Mule scopes 2
 
Mule scopes 1
Mule scopes 1Mule scopes 1
Mule scopes 1
 
Mule debugging logging_configuration_in_mule
Mule debugging logging_configuration_in_muleMule debugging logging_configuration_in_mule
Mule debugging logging_configuration_in_mule
 
Mule debugging logging_in_mule
Mule debugging logging_in_muleMule debugging logging_in_mule
Mule debugging logging_in_mule
 
Mule debugging managing_stack_traces
Mule debugging managing_stack_tracesMule debugging managing_stack_traces
Mule debugging managing_stack_traces
 
Mule error handling_rollback exception strategy
Mule error handling_rollback exception strategyMule error handling_rollback exception strategy
Mule error handling_rollback exception strategy
 
Mule message
Mule messageMule message
Mule message
 
Mule error handling_choice exception strategy
Mule error handling_choice exception strategyMule error handling_choice exception strategy
Mule error handling_choice exception strategy
 
Mule concepts exception strategies
Mule concepts exception strategiesMule concepts exception strategies
Mule concepts exception strategies
 
Mule concepts filters scopes_routers
Mule concepts filters scopes_routersMule concepts filters scopes_routers
Mule concepts filters scopes_routers
 

Recently uploaded

AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Game Development with Unity3D (Game Development lecture 3)
Game Development  with Unity3D (Game Development lecture 3)Game Development  with Unity3D (Game Development lecture 3)
Game Development with Unity3D (Game Development lecture 3)
abdulrafaychaudhry
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
QuickwayInfoSystems3
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 

Recently uploaded (20)

AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Game Development with Unity3D (Game Development lecture 3)
Game Development  with Unity3D (Game Development lecture 3)Game Development  with Unity3D (Game Development lecture 3)
Game Development with Unity3D (Game Development lecture 3)
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 

Mule mel 5_tips

  • 1. Mule Concepts Mule Expression Language (MEL) Basics -V
  • 2. • Payload and Attachments – To copy the current payload in a flow variable named originalPayload then restore it : <set-variable variableName="originalPayload" value="#[message.payload]" /> <set-payload value="#[originalPayload]" /> – To retrieve the message payload in a particular format, using Mule’s auto-transformation capability, use payloadAs: <logger message="#[message.payloadAs(java.lang.String)]" /> – To extract all .txt and .xml attachments, use a filtered projection: <expression-transformer expression="#[($.value in message.inboundAttachments.entrySet() if $.key ~= '(.*.txt|.*.xml)')]" /> – To ask for a null payload: #[payload is NullPayload] Mule Expression Language (MEL)
  • 3. • Regex Support – Regular expression helper functions retrieve null, a single value or an array of values, depending on matches. – The forms that take a melExpression argument apply the regex to the result of its evaluation instead of message.payload. #[regex(regularExpression [, melExpression [, matchFlags]])] – Example : • to select all the lines of the payload that begin with To:, From:, or Cc: use: #[regex('^(To|From|Cc):')] Mule Expression Language (MEL)
  • 4. • XPath Support – XPath helper functions return DOM4J nodes. – By default the XPath expression is evaluated onmessage.payload unless an xmlElement is specified: #[xpath3(xPathExpression [, xmlElement])] – To get the text content of an element or an attribute: #[xpath3('//title').text] #[xpath3('//title/@id').value] Mule Expression Language (MEL)
  • 5. • JSON Processing – MEL has no direct support for JSON. – The json-to-object-transformer can turn a JSON payload into a hierarchy of simple data structures that are easily parsed with MEL. – For the equivalent of this JSON path expression: $..[? (@.title=='Moby Dick')].price The following uses a filtered projection: <json:json-to-object-transformer returnClass="java.lang.Object" /> <expression-transformer expression='#[($.price in message.payload if $.title =='Moby Dick')[0]]" /> Mule Expression Language (MEL)
  • 6. • Including DataWeave code – You can carry out powerful complex data transformations by including MEL DataWeave Functionsthat use DataWeave Language code. – You can include this code via two different functions in MEL: 'dw()' and 'split()'. – 'dw' simply executes the DataWeave code you pass as an argument and returns the transformation’s result – 'split()' executes the code you pass as an argument and returns an iterator that allows you to process each instance of the output as a separate message. dw("myobject:{id:payload.accountid, user:payload.user}") Mule Expression Language (MEL)
  • 7. • Miscellaneous Operations – Assign to variable lastname the value of the message inbound property lastname: #[lastname = message.inboundProperties.lastname] – Append a string to the message payload: #[message.payload + 'mystring'] – Call a static method: #[java.net.URLEncoder.encode()] – Create a hash map: #[new java.util.HashMap()] Mule Expression Language (MEL)