SlideShare a Scribd company logo
DATAWEAVE IN MULE
Using the DataWeave Transformer
• In Anypoint Studio, you can place a Transform
Message element in a flow to create transformations
using the DataWeave language.
• The editor helps you do this by offering intelligent
autocomplete suggestions, an output preview that is
updated in real time as you make changes.
• This generates a .dwl transformation file (or several of
them) that stores your code and is packaged with your
Mule application.
• When adding a Transform Message element to a Mule
Flow, it takes the elements from the incoming Mule
Message as its inputs. It then performs the necessary
actions to produce a Mule message as output for the next
element in the flow
• The DataWeave Text Editor GUI
• The Transform Message element allows you to freely
write DataWeave code.
• If you click on an instance of the Transform Message
element in your flow, its properties editor will be displayed.
This editor is divided into three sections:
• Input
• Transform
• Output
Input Section
In the main tab, a tree view shows the known metadata
contents of the incoming Mule Message, allowing you to
explore it and know what data is available for using as an
input, and how to reference each part of it.
If the Mule flow doesn’t expose Metadata about the
elements you need from the incoming message, you can
manually specify it. To do so, select the element of the input
you desire to define, note that the pencil icon at the top
right is no longer grayed out. Click this icon to open a new
tab in your input section where you can define a sample
with the structure of this data.
When the input is of JSON or XML types, the sample input contains plain XML or
JSON code. When the input is of type POJO or DataWeave, the sample input is
written in DataWeave for more simplicity. In these cases the sample DataWeave code
is merely a way to display the sample data, not a transformation in itself.
Setting Reader Parameters
• Some input formats, like CSV, allow you to define
a reader with specific properties that make
DataWeave parse inputs differently. Select the
input element you wish to configure on the tree
view of the input section, then click the gear icon.
Transform Section
• you write the actual DataWeave code that carries out the
transform. Notice that changing the type of your output
directive changes the output section of the editor.
Although DataWeave as a language supports adding
input directives and naming these by any name you like,
in Studio the elements of the input message are implicitly
considered input directives and so they don’t need to be
defined in the header.
If Studio has any metadata about the components that are
upstream or downstream from your Transform Message
element at the time when you add the component to your
flow, a scaffolding for your DataWeave code is written out
automatically, with as much depth as Studio can
intelligently deduce. In some cases, this code may be
enough to carry out the transformation you need, and no
additional coding is needed. Sometimes, all you need to do
is fill in the blank spaces in the scaffolding with references
to the input fields, other times you may want to carry out
more complex operations that involve aggregation, filtering,
calculations, defining custom functions, etc and there you
must write this out in DataWeave code.
Re-scaffolding
• Once you’ve added the Transform Message element to
your flow, any further changes you make to the
surrounding message processors and their metadata
won’t affect your `.dw`l file. You may still click the
Scaffolding button on the top left of the DataWeave
properties editor any time you want and have a new
scaffolding built, note that this will erase anything you’ve
written in the DataWeave body. Doing this won’t affect
any directives you defined in your header (except for the
output directive). Use this button if you’ve made any
changes to elements that come after the Transform
Message element on the flow that expose metadata and
don’t mind loosing what you’ve already written into the
transform’s body.
Referencing Existing Transforms
Instead of defining a new .dwl file, you can reference an
existing one by clicking theData Source button,
selecting On File as the source and referencing the correct
file.
Handling Multiple Outputs
A single Transform Message element can give shape to
several different components of the output Mule message.
Each of these output components must be defined in a
separate .dwl file, written out in a separate tab of the
Transform section. For example in one tab you may be
defining the payload contents, in another those of an
outbound property, and these will both be parts of the same
output Mule message
To add a new output, click the Plus sign at the
bottom right of the section:new+output.png[image]
A new tab will then appear, there you can specify
where in the output Mule message to place the
output of this DataWeave transform. In case you’re
creating a new variable or property, you must also
set a name for it.
In the XML editor you can do the same by adding multiple
child elements inside thedw:transform-message component.
<dw:transform-message>
<dw:set-payload resource="classpath:path/transform.dwl"/> <dw:set-
variable variableName="myVariable"
resource="classpath:path/transform.dwl"/> <dw:set-session-variable
variableName="mySessionVariable"
resource="classpath:path/transform.dwl"/> </dw:transform-message>
Output Section
• This section has two tabs, one of them shows you a neat
expandable tree view of the output data structure, the other
shows you a preview of what the actual output looks like, built
from any sample data you provide in the input section. As you
make changes in the transport section, notice how the data
structure changes. The output of the transformer is made into
the selected component of the output mule message. If your
transformer has multiple outputs, the Preview tab will display
the one corresponding to the currently selected transform.
Using DataWeave Language Elsewhere
• All components in Mule that support Mule Expression
Language also support expressions written in DataWeave
Language. To invoke an expression written in DataWeave
language, simply invoke the dw() function, the expression will
return whatever the transform outputs.
• DataWeave expressions defined within this function work just
as those defined within a Transform Message element, the only
difference is that the output is returned into the expression’s
result, wherever it may be.
• For example, you can define a custom object and
populate it with elements from the payload:
• That same expression could be added inside a Logger,
• within a MEL expression, to print out its result:
dw(myobject:{id:payload.accountid, user:payload.user})
#[`dw(myobject:{id:payload.accountid, user:payload.user})`]

More Related Content

What's hot

Oracle Form material
Oracle Form materialOracle Form material
Oracle Form material
Rajesh Ch
 
OBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - TutorialOBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - Tutorial
onlinetrainingplacements
 
Murach: How to use Entity Framework EF Core
Murach: How to use Entity Framework EF  CoreMurach: How to use Entity Framework EF  Core
Murach: How to use Entity Framework EF Core
MahmoudOHassouna
 
Generic steps in informatica
Generic steps in informaticaGeneric steps in informatica
Generic steps in informatica
Bhuvana Priya
 
Reports 6i
Reports 6iReports 6i
Reports 6i
Senthamarai B
 
Responsive Design and Bootstrap
Responsive Design  and BootstrapResponsive Design  and Bootstrap
Responsive Design and Bootstrap
MahmoudOHassouna
 
d2k
d2kd2k
SQL Commands
SQL Commands SQL Commands
SQL Commands
Divyank Jindal
 
VB6 Using ADO Data Control
VB6 Using ADO Data ControlVB6 Using ADO Data Control
VB6 Using ADO Data Control
Notre Dame of Midsayap College
 
Oracle Certification 1Z0-1041 Questions and Answers
Oracle Certification 1Z0-1041 Questions and AnswersOracle Certification 1Z0-1041 Questions and Answers
Oracle Certification 1Z0-1041 Questions and Answers
douglascarnicelli
 
Oracle SQL Advanced
Oracle SQL AdvancedOracle SQL Advanced
Oracle SQL Advanced
Dhananjay Goel
 
SQL Tunning
SQL TunningSQL Tunning
SQL Tunning
Dhananjay Goel
 

What's hot (12)

Oracle Form material
Oracle Form materialOracle Form material
Oracle Form material
 
OBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - TutorialOBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - Tutorial
 
Murach: How to use Entity Framework EF Core
Murach: How to use Entity Framework EF  CoreMurach: How to use Entity Framework EF  Core
Murach: How to use Entity Framework EF Core
 
Generic steps in informatica
Generic steps in informaticaGeneric steps in informatica
Generic steps in informatica
 
Reports 6i
Reports 6iReports 6i
Reports 6i
 
Responsive Design and Bootstrap
Responsive Design  and BootstrapResponsive Design  and Bootstrap
Responsive Design and Bootstrap
 
d2k
d2kd2k
d2k
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
VB6 Using ADO Data Control
VB6 Using ADO Data ControlVB6 Using ADO Data Control
VB6 Using ADO Data Control
 
Oracle Certification 1Z0-1041 Questions and Answers
Oracle Certification 1Z0-1041 Questions and AnswersOracle Certification 1Z0-1041 Questions and Answers
Oracle Certification 1Z0-1041 Questions and Answers
 
Oracle SQL Advanced
Oracle SQL AdvancedOracle SQL Advanced
Oracle SQL Advanced
 
SQL Tunning
SQL TunningSQL Tunning
SQL Tunning
 

Similar to Data weave

Dataweave nagarjuna
Dataweave nagarjunaDataweave nagarjuna
Dataweave nagarjuna
Nagarjuna reddy
 
Data weave
Data weave Data weave
Data weave
Khasim Saheb
 
Data weave
Data weave Data weave
Data weave
Anand kalla
 
Data weave
Data weave Data weave
Data weave
Sunil Komarapu
 
Dataweave 160103180124
Dataweave 160103180124Dataweave 160103180124
Dataweave 160103180124
vijay dhanakodi
 
Mule data weave
Mule data weaveMule data weave
Mule data weave
D.Rajesh Kumar
 
Data weave
Data weaveData weave
Data weave
Adithya-kuchan
 
Dataweave in studio
Dataweave in studioDataweave in studio
Dataweave in studio
Achyuta Lakshmi Puvvala
 
Data weave in mule
Data weave in muleData weave in mule
Data weave in mule
Ramakrishna kapa
 
Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200
harika thamishetti
 
Mule dataweave
Mule dataweaveMule dataweave
Mule dataweave
Son Nguyen
 
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 data weave_2
Mule data weave_2Mule data weave_2
Mule data weave_2
kunal vishe
 
Mule dataweave
Mule dataweaveMule dataweave
Mule data weave_3
Mule data weave_3Mule data weave_3
Mule data weave_3
kunal vishe
 
Mule with data weave
Mule with data weaveMule with data weave
Mule with data weave
Son Nguyen
 
Mca 504 dotnet_unit5
Mca 504 dotnet_unit5Mca 504 dotnet_unit5
2 designer
2 designer2 designer
2 designer
Ravindra Gangwar
 
Data weave (MuleSoft)
Data weave (MuleSoft)Data weave (MuleSoft)
Data weave (MuleSoft)
Nandu List5
 
Oracle report from ppt
Oracle report from pptOracle report from ppt
Oracle report from ppt
kingshuk_goswami
 

Similar to Data weave (20)

Dataweave nagarjuna
Dataweave nagarjunaDataweave nagarjuna
Dataweave nagarjuna
 
Data weave
Data weave Data weave
Data weave
 
Data weave
Data weave Data weave
Data weave
 
Data weave
Data weave Data weave
Data weave
 
Dataweave 160103180124
Dataweave 160103180124Dataweave 160103180124
Dataweave 160103180124
 
Mule data weave
Mule data weaveMule data weave
Mule data weave
 
Data weave
Data weaveData weave
Data weave
 
Dataweave in studio
Dataweave in studioDataweave in studio
Dataweave in studio
 
Data weave in mule
Data weave in muleData weave in mule
Data weave in mule
 
Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200
 
Mule dataweave
Mule dataweaveMule dataweave
Mule dataweave
 
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 data weave_2
Mule data weave_2Mule data weave_2
Mule data weave_2
 
Mule dataweave
Mule dataweaveMule dataweave
Mule dataweave
 
Mule data weave_3
Mule data weave_3Mule data weave_3
Mule data weave_3
 
Mule with data weave
Mule with data weaveMule with data weave
Mule with data weave
 
Mca 504 dotnet_unit5
Mca 504 dotnet_unit5Mca 504 dotnet_unit5
Mca 504 dotnet_unit5
 
2 designer
2 designer2 designer
2 designer
 
Data weave (MuleSoft)
Data weave (MuleSoft)Data weave (MuleSoft)
Data weave (MuleSoft)
 
Oracle report from ppt
Oracle report from pptOracle report from ppt
Oracle report from ppt
 

More from irfan1008

Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformer
irfan1008
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
irfan1008
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
irfan1008
 
Mule
MuleMule
Mule
irfan1008
 
Groovy with Mule
Groovy with MuleGroovy with Mule
Groovy with Mule
irfan1008
 
Validate Soap Request in Mule
Validate Soap Request in MuleValidate Soap Request in Mule
Validate Soap Request in Mule
irfan1008
 
WebService with VM Mule
WebService with VM MuleWebService with VM Mule
WebService with VM Mule
irfan1008
 
Xslt in mule
Xslt in muleXslt in mule
Xslt in mule
irfan1008
 
Developing Oracle Connector Using Mule
Developing Oracle Connector Using MuleDeveloping Oracle Connector Using Mule
Developing Oracle Connector Using Mule
irfan1008
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
irfan1008
 
Mule oracle connectors
Mule oracle connectorsMule oracle connectors
Mule oracle connectors
irfan1008
 
Mule google connectors
Mule google connectorsMule google connectors
Mule google connectors
irfan1008
 
Mule execution
Mule executionMule execution
Mule execution
irfan1008
 
Mule database-connectors
Mule database-connectorsMule database-connectors
Mule database-connectors
irfan1008
 
Mule batch processing
Mule batch processingMule batch processing
Mule batch processing
irfan1008
 
Mule architecture
Mule architectureMule architecture
Mule architecture
irfan1008
 
Mule anypoint exchange
Mule anypoint exchangeMule anypoint exchange
Mule anypoint exchange
irfan1008
 
Mule soap
Mule soapMule soap
Mule soap
irfan1008
 
Mule soa
Mule soaMule soa
Mule soa
irfan1008
 
Mule security saml
Mule security samlMule security saml
Mule security saml
irfan1008
 

More from irfan1008 (20)

Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformer
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 
Mule
MuleMule
Mule
 
Groovy with Mule
Groovy with MuleGroovy with Mule
Groovy with Mule
 
Validate Soap Request in Mule
Validate Soap Request in MuleValidate Soap Request in Mule
Validate Soap Request in Mule
 
WebService with VM Mule
WebService with VM MuleWebService with VM Mule
WebService with VM Mule
 
Xslt in mule
Xslt in muleXslt in mule
Xslt in mule
 
Developing Oracle Connector Using Mule
Developing Oracle Connector Using MuleDeveloping Oracle Connector Using Mule
Developing Oracle Connector Using Mule
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
 
Mule oracle connectors
Mule oracle connectorsMule oracle connectors
Mule oracle connectors
 
Mule google connectors
Mule google connectorsMule google connectors
Mule google connectors
 
Mule execution
Mule executionMule execution
Mule execution
 
Mule database-connectors
Mule database-connectorsMule database-connectors
Mule database-connectors
 
Mule batch processing
Mule batch processingMule batch processing
Mule batch processing
 
Mule architecture
Mule architectureMule architecture
Mule architecture
 
Mule anypoint exchange
Mule anypoint exchangeMule anypoint exchange
Mule anypoint exchange
 
Mule soap
Mule soapMule soap
Mule soap
 
Mule soa
Mule soaMule soa
Mule soa
 
Mule security saml
Mule security samlMule security saml
Mule security saml
 

Recently uploaded

Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
flufftailshop
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 

Recently uploaded (20)

Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 

Data weave

  • 2. Using the DataWeave Transformer • In Anypoint Studio, you can place a Transform Message element in a flow to create transformations using the DataWeave language. • The editor helps you do this by offering intelligent autocomplete suggestions, an output preview that is updated in real time as you make changes. • This generates a .dwl transformation file (or several of them) that stores your code and is packaged with your Mule application.
  • 3. • When adding a Transform Message element to a Mule Flow, it takes the elements from the incoming Mule Message as its inputs. It then performs the necessary actions to produce a Mule message as output for the next element in the flow
  • 4. • The DataWeave Text Editor GUI • The Transform Message element allows you to freely write DataWeave code. • If you click on an instance of the Transform Message element in your flow, its properties editor will be displayed. This editor is divided into three sections: • Input • Transform • Output
  • 5. Input Section In the main tab, a tree view shows the known metadata contents of the incoming Mule Message, allowing you to explore it and know what data is available for using as an input, and how to reference each part of it. If the Mule flow doesn’t expose Metadata about the elements you need from the incoming message, you can manually specify it. To do so, select the element of the input you desire to define, note that the pencil icon at the top right is no longer grayed out. Click this icon to open a new tab in your input section where you can define a sample with the structure of this data.
  • 6. When the input is of JSON or XML types, the sample input contains plain XML or JSON code. When the input is of type POJO or DataWeave, the sample input is written in DataWeave for more simplicity. In these cases the sample DataWeave code is merely a way to display the sample data, not a transformation in itself.
  • 7. Setting Reader Parameters • Some input formats, like CSV, allow you to define a reader with specific properties that make DataWeave parse inputs differently. Select the input element you wish to configure on the tree view of the input section, then click the gear icon.
  • 8. Transform Section • you write the actual DataWeave code that carries out the transform. Notice that changing the type of your output directive changes the output section of the editor. Although DataWeave as a language supports adding input directives and naming these by any name you like, in Studio the elements of the input message are implicitly considered input directives and so they don’t need to be defined in the header.
  • 9. If Studio has any metadata about the components that are upstream or downstream from your Transform Message element at the time when you add the component to your flow, a scaffolding for your DataWeave code is written out automatically, with as much depth as Studio can intelligently deduce. In some cases, this code may be enough to carry out the transformation you need, and no additional coding is needed. Sometimes, all you need to do is fill in the blank spaces in the scaffolding with references to the input fields, other times you may want to carry out more complex operations that involve aggregation, filtering, calculations, defining custom functions, etc and there you must write this out in DataWeave code.
  • 10. Re-scaffolding • Once you’ve added the Transform Message element to your flow, any further changes you make to the surrounding message processors and their metadata won’t affect your `.dw`l file. You may still click the Scaffolding button on the top left of the DataWeave properties editor any time you want and have a new scaffolding built, note that this will erase anything you’ve written in the DataWeave body. Doing this won’t affect any directives you defined in your header (except for the output directive). Use this button if you’ve made any changes to elements that come after the Transform Message element on the flow that expose metadata and don’t mind loosing what you’ve already written into the transform’s body.
  • 11. Referencing Existing Transforms Instead of defining a new .dwl file, you can reference an existing one by clicking theData Source button, selecting On File as the source and referencing the correct file.
  • 12. Handling Multiple Outputs A single Transform Message element can give shape to several different components of the output Mule message. Each of these output components must be defined in a separate .dwl file, written out in a separate tab of the Transform section. For example in one tab you may be defining the payload contents, in another those of an outbound property, and these will both be parts of the same output Mule message
  • 13. To add a new output, click the Plus sign at the bottom right of the section:new+output.png[image] A new tab will then appear, there you can specify where in the output Mule message to place the output of this DataWeave transform. In case you’re creating a new variable or property, you must also set a name for it.
  • 14. In the XML editor you can do the same by adding multiple child elements inside thedw:transform-message component. <dw:transform-message> <dw:set-payload resource="classpath:path/transform.dwl"/> <dw:set- variable variableName="myVariable" resource="classpath:path/transform.dwl"/> <dw:set-session-variable variableName="mySessionVariable" resource="classpath:path/transform.dwl"/> </dw:transform-message>
  • 15. Output Section • This section has two tabs, one of them shows you a neat expandable tree view of the output data structure, the other shows you a preview of what the actual output looks like, built from any sample data you provide in the input section. As you make changes in the transport section, notice how the data structure changes. The output of the transformer is made into the selected component of the output mule message. If your transformer has multiple outputs, the Preview tab will display the one corresponding to the currently selected transform.
  • 16. Using DataWeave Language Elsewhere • All components in Mule that support Mule Expression Language also support expressions written in DataWeave Language. To invoke an expression written in DataWeave language, simply invoke the dw() function, the expression will return whatever the transform outputs. • DataWeave expressions defined within this function work just as those defined within a Transform Message element, the only difference is that the output is returned into the expression’s result, wherever it may be.
  • 17. • For example, you can define a custom object and populate it with elements from the payload: • That same expression could be added inside a Logger, • within a MEL expression, to print out its result: dw(myobject:{id:payload.accountid, user:payload.user}) #[`dw(myobject:{id:payload.accountid, user:payload.user})`]