SlideShare a Scribd company logo
1 of 9
Mule Concepts
DataWeave X
• Calling Global MEL Functions from DataWeave Code :
– If you define a global Mule Expression Language (MEL) function in your
Mule project, you can then invoke it anywhere in your DataWeave
code, without need for any special syntax.
– To create one such global function, you must edit your Mule project’s
XML file and enclose any functions that you wish to define in the
following set of tags
<configuration doc:name="Configuration">
<expression-language>
<global-functions>
</global-functions>
</expression-language>
</configuration>
DataWeave – Body
• Calling Global MEL Functions from DataWeave Code :
– This global MEL function must be placed in the global elements
section, before any of the flows are defined.
– In the empty space in the tags shown in previous slide, you can use
any MEL expression to define custom functions.
– Example :
<configuration doc:name="Configuration">
<expression-language>
<global-functions>
def newUser() {
return ["name" : "mariano"]
}
def upperName(user) {
return user.name.toUpperCase()
}
</global-functions>
</expression-language>
</configuration>
DataWeave – Body
• Calling Global MEL Functions from DataWeave Code :
– With the MEL global function in place, in the DataWeave code
of your Transform Message element you can just refer to these
functions.
– Note that the inputs and outputs of these functions can even be
objects and arrays.
– Example :
%dw 1.0
%output application/json
---
{
"foo" : newUser(),
"bar": upperName(newUser())
}
– Even with these external functions in place, you should be able
to preview the output of this transform, updated in real time
as you edit it.
DataWeave – Body
• Read :
– The read function returns the result of parsing the content parameter
with the specified mimeType reader.
– It accepts three parameters :
• The first argument points the content that must be read.
• The second is the format in which to write it.
• A third optional argument lists reader configuration properties.
– Example :
– In the example above, what was in the CDATA element isn’t parsed by
the DataWeave reader by default, that’s why the read operator must
be used to interpret it.
DataWeave – Body
Transform Input Output
%dw 1.0
%output application/xml
---
output: read(payload.root.xmlblock,
"application/xml").foo
<?xml version='1.0' encoding='UTF-
8'?>
<root>
<xmlblock><![CDATA[<foo>bar</foo>]]
></xmlblock>
</root>
<?xml version='1.0'
encoding='UTF-8'?>
<output>bar</output>
• Write :
– The write function returns a string with the serialized representation
of the value in the specified mimeType.
– It accepts three parameters :
• The first argument points to the element that must be written.
• the second is the format in which to write it.
• A third optional argument lists writer configuration properties.
– Example :
DataWeave – Body
Transform Input Output
%dw 1.0
%output application/xml
---
{
output: write(payload,
"application/csv",
{"separator" : "|"})
}
"Name": "Mr White",
"Email": "white@mulesoft.com",
"Id": "1234",
"Title": "Chief Java Prophet"
},
{
"Name": "Mr Orange",
"Email": "orange@mulesoft.com",
"Id": "4567",
"Title": "Integration Ninja"
}
]
<?xml version='1.0' encoding='US-
ASCII'?>
<output>Name|Email|Id|Title
Mr
White|white@mulesoft.com|1234|Chief
Java Prophet
Mr
Orange|orange@mulesoft.com|4567|Int
egration Ninja
</output>
• Log :
– Returns the specified value and also logs the value in the DataWeave
representation with the specified prefix.
– Example :
– Note that besides producing the expected output, it also logs it.
DataWeave – Body
Transform Output Output To Logger
%dw 1.0
%output application/json
---
{
result: log("Logging the
array",[1,2,3,4])
}
{
"result": [1,2,3,4]
}
Logging the array [1,2,3,4]
• Calling External Flows
– you can trigger the calling of a different flow in your Mule
application from a DataWeave transform, through the
following expression:
lookup(“flowName”,$)
Which takes two parameters:
• The name of the flow that must be called
• The payload to send to this flow, as a map
DataWeave – Body –External Flows
• Calling External Flows
– Example :
– note that only the payload returned by the invoked flow
will be assigned (i.e. all other message’s properties such as
flowVars and sessionVars will not be overridden when
using the lookup function).
– The lookup function does not support calling subflows.
DataWeave – Body –External Flows
Transform Mule Flow Output
%dw 1.0
%output application/json
---
{
a: lookup("mySecondFlow",{b:"Hello"})
}
<flow name="mySecondFlow">
<set-payload doc:name="Set
Payload" value="#[payload.b + '
world!' ]"/>
</flow>
{
"a": "Hello world!"
}

More Related Content

What's hot

What's hot (20)

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
 
Data weave documentation
Data weave documentationData weave documentation
Data weave documentation
 
Data weave component
Data weave componentData weave component
Data weave 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
 
Integrate with database by groovy
Integrate with database by groovyIntegrate with database by groovy
Integrate with database by groovy
 
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
 
Mule expression component
Mule expression componentMule expression component
Mule expression component
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo
 
MuleSoft ESB scatter-gather and base64
MuleSoft ESB scatter-gather and base64MuleSoft ESB scatter-gather and base64
MuleSoft ESB scatter-gather and base64
 
Dataweave nagarjuna
Dataweave nagarjunaDataweave nagarjuna
Dataweave nagarjuna
 
Mule xml transformation
Mule xml transformationMule xml transformation
Mule xml transformation
 
Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mule
 
MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher
 
Data weave documentation
Data weave documentationData weave documentation
Data weave documentation
 
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
 
Mule esb :Data Weave
Mule esb :Data WeaveMule esb :Data Weave
Mule esb :Data Weave
 
Mule jdbc
Mule   jdbcMule   jdbc
Mule jdbc
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Using XSLT in Mule
Using XSLT in MuleUsing XSLT in Mule
Using XSLT in Mule
 
Message properties component in Mule
Message properties component in MuleMessage properties component in Mule
Message properties component in Mule
 

Viewers also liked (8)

Mule data weave_7
Mule data weave_7Mule data weave_7
Mule data weave_7
 
Variables in dataweave
Variables in dataweaveVariables in dataweave
Variables in dataweave
 
Mule mel 3
Mule mel 3Mule mel 3
Mule mel 3
 
Mule scopes async_scope
Mule scopes async_scopeMule scopes async_scope
Mule scopes async_scope
 
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
 
10 Useful Asciidoctor Tips
10 Useful Asciidoctor Tips10 Useful Asciidoctor Tips
10 Useful Asciidoctor Tips
 
Mule soft mel_session_3
Mule soft mel_session_3Mule soft mel_session_3
Mule soft mel_session_3
 

Similar to Mule data weave_10

WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalyst
svilen.ivanov
 

Similar to Mule data weave_10 (20)

Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200
 
Generating Code with Oracle SQL Developer Data Modeler
Generating Code with Oracle SQL Developer Data ModelerGenerating Code with Oracle SQL Developer Data Modeler
Generating Code with Oracle SQL Developer Data Modeler
 
treeview
treeviewtreeview
treeview
 
treeview
treeviewtreeview
treeview
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database Deployments
 
Warsaw Frontend Meetup #1 - Webpack
Warsaw Frontend Meetup #1 - WebpackWarsaw Frontend Meetup #1 - Webpack
Warsaw Frontend Meetup #1 - Webpack
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalyst
 
Analytics Metrics delivery and ML Feature visualization: Evolution of Data Pl...
Analytics Metrics delivery and ML Feature visualization: Evolution of Data Pl...Analytics Metrics delivery and ML Feature visualization: Evolution of Data Pl...
Analytics Metrics delivery and ML Feature visualization: Evolution of Data Pl...
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Google cloud Dataflow & Apache Flink
Google cloud Dataflow & Apache FlinkGoogle cloud Dataflow & Apache Flink
Google cloud Dataflow & Apache Flink
 
Mysql
MysqlMysql
Mysql
 
Using the Features API
Using the Features APIUsing the Features API
Using the Features API
 
Airflow presentation
Airflow presentationAirflow presentation
Airflow presentation
 
Lobos Introduction
Lobos IntroductionLobos Introduction
Lobos Introduction
 
Introduction to Mangento
Introduction to Mangento Introduction to Mangento
Introduction to Mangento
 
Mangento
MangentoMangento
Mangento
 
Jsp and jstl
Jsp and jstlJsp and jstl
Jsp and jstl
 
Database programming
Database programmingDatabase programming
Database programming
 

More from kunal vishe

More from kunal vishe (20)

Mule mel 4_tips
Mule mel 4_tipsMule mel 4_tips
Mule mel 4_tips
 
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 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
 
Mule concepts transformers
Mule concepts transformersMule concepts transformers
Mule concepts transformers
 
Mule concepts components
Mule concepts componentsMule concepts components
Mule concepts components
 
Mule concepts connectors
Mule concepts connectorsMule concepts connectors
Mule concepts connectors
 
Mule concepts elements in a mule flow
Mule concepts elements in a mule flowMule concepts elements in a mule flow
Mule concepts elements in a mule flow
 
Mule concepts flows
Mule concepts flowsMule concepts flows
Mule concepts flows
 

Recently uploaded

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 

Recently uploaded (20)

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 

Mule data weave_10

  • 2. • Calling Global MEL Functions from DataWeave Code : – If you define a global Mule Expression Language (MEL) function in your Mule project, you can then invoke it anywhere in your DataWeave code, without need for any special syntax. – To create one such global function, you must edit your Mule project’s XML file and enclose any functions that you wish to define in the following set of tags <configuration doc:name="Configuration"> <expression-language> <global-functions> </global-functions> </expression-language> </configuration> DataWeave – Body
  • 3. • Calling Global MEL Functions from DataWeave Code : – This global MEL function must be placed in the global elements section, before any of the flows are defined. – In the empty space in the tags shown in previous slide, you can use any MEL expression to define custom functions. – Example : <configuration doc:name="Configuration"> <expression-language> <global-functions> def newUser() { return ["name" : "mariano"] } def upperName(user) { return user.name.toUpperCase() } </global-functions> </expression-language> </configuration> DataWeave – Body
  • 4. • Calling Global MEL Functions from DataWeave Code : – With the MEL global function in place, in the DataWeave code of your Transform Message element you can just refer to these functions. – Note that the inputs and outputs of these functions can even be objects and arrays. – Example : %dw 1.0 %output application/json --- { "foo" : newUser(), "bar": upperName(newUser()) } – Even with these external functions in place, you should be able to preview the output of this transform, updated in real time as you edit it. DataWeave – Body
  • 5. • Read : – The read function returns the result of parsing the content parameter with the specified mimeType reader. – It accepts three parameters : • The first argument points the content that must be read. • The second is the format in which to write it. • A third optional argument lists reader configuration properties. – Example : – In the example above, what was in the CDATA element isn’t parsed by the DataWeave reader by default, that’s why the read operator must be used to interpret it. DataWeave – Body Transform Input Output %dw 1.0 %output application/xml --- output: read(payload.root.xmlblock, "application/xml").foo <?xml version='1.0' encoding='UTF- 8'?> <root> <xmlblock><![CDATA[<foo>bar</foo>]] ></xmlblock> </root> <?xml version='1.0' encoding='UTF-8'?> <output>bar</output>
  • 6. • Write : – The write function returns a string with the serialized representation of the value in the specified mimeType. – It accepts three parameters : • The first argument points to the element that must be written. • the second is the format in which to write it. • A third optional argument lists writer configuration properties. – Example : DataWeave – Body Transform Input Output %dw 1.0 %output application/xml --- { output: write(payload, "application/csv", {"separator" : "|"}) } "Name": "Mr White", "Email": "white@mulesoft.com", "Id": "1234", "Title": "Chief Java Prophet" }, { "Name": "Mr Orange", "Email": "orange@mulesoft.com", "Id": "4567", "Title": "Integration Ninja" } ] <?xml version='1.0' encoding='US- ASCII'?> <output>Name|Email|Id|Title Mr White|white@mulesoft.com|1234|Chief Java Prophet Mr Orange|orange@mulesoft.com|4567|Int egration Ninja </output>
  • 7. • Log : – Returns the specified value and also logs the value in the DataWeave representation with the specified prefix. – Example : – Note that besides producing the expected output, it also logs it. DataWeave – Body Transform Output Output To Logger %dw 1.0 %output application/json --- { result: log("Logging the array",[1,2,3,4]) } { "result": [1,2,3,4] } Logging the array [1,2,3,4]
  • 8. • Calling External Flows – you can trigger the calling of a different flow in your Mule application from a DataWeave transform, through the following expression: lookup(“flowName”,$) Which takes two parameters: • The name of the flow that must be called • The payload to send to this flow, as a map DataWeave – Body –External Flows
  • 9. • Calling External Flows – Example : – note that only the payload returned by the invoked flow will be assigned (i.e. all other message’s properties such as flowVars and sessionVars will not be overridden when using the lookup function). – The lookup function does not support calling subflows. DataWeave – Body –External Flows Transform Mule Flow Output %dw 1.0 %output application/json --- { a: lookup("mySecondFlow",{b:"Hello"}) } <flow name="mySecondFlow"> <set-payload doc:name="Set Payload" value="#[payload.b + ' world!' ]"/> </flow> { "a": "Hello world!" }