<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">
<data-mapper:config name="new_mapping_grf" transformationGraphPath="new_mapping.grf" doc:name="DataMapper"/>
<data-mapper:config name="map_to_csv" transformationGraphPath="map_to_csv.grf" doc:name="map_to_csv"/>
<!-- Example 1 Start - How to access properties using MEL, how to set a payload dynamically -->
<flow name="greetingFlow1" doc:name="greetingFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="greet1" doc:name="HTTP"/>
<set-payload value="Hello #[message.inboundProperties['username']]" doc:name="Set Payload"/>
</flow>
<!-- Example 1 End -->
<!-- Example 2 Start - How to dynamically route messages based on the results of a conditional expression -->
<flow name="greetingFlow2" doc:name="greetingFlow2">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="greet2" doc:name="HTTP"/>
<choice doc:name="Choice">
<when expression="#[message.inboundProperties['username'] == empty]">
<set-payload value="#['No username provided']" doc:name="Set Payload for invalid username"/>
</when>
<otherwise>
<set-payload value="Hello #[message.inboundProperties['username']]" doc:name="Set Payload for valid username"/>
</otherwise>
</choice>
</flow>
<!-- Example 2 End -->
<!-- Example 3 Start - How to assign variables, how to evaluate a condition -->
<flow name="docs-greetingFlow3" doc:name="greetingFlow3">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="greet3" doc:name="HTTP"/>
<expression-component doc:name="Expression"><![CDATA[flowVars['username'] = message.inboundProperties['username']]]></expression-component>
<set-payload value="#[message.inboundProperties['username']], #[message.inboundProperties['age']], #[message.inboundProperties['age']>18]" doc:name="Set Payload"/>
<file:outbound-endpoint path="Path_of_your_choice" responseTimeout="10000" doc:name="File"/>
<set-payload value="Hello #[flowVars['username']]" doc:name="Set Payload"/>
</flow>
<!-- Example 3 End -->
<!-- Example 4 Start - How to create a map, how to evaluate a condition with DataMapper -->
<flow name="docs-greetingFlow4" doc:name="greetingFlow4">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="greet4" doc:name="HTTP"/>
<expression-component doc:name="Expression"><![CDATA[flowVars['username'] = message.inboundProperties['username']]]></expression-component>
<set-payload value="#[['username' : message.inboundProperties['username'], 'age' : message.inboundProperties['age']]]" doc:name="Set Payload"/>
<data-mapper:transform config-ref="map_to_csv" doc:name="Map To CSV"/>
<file:outbound-endpoint path="Path_of_your_choice" responseTimeout="10000" doc:name="File"/>
<set-payload value="Hello #[flowVars['username']]" doc:name="Set Payload"/>
</flow>
<!-- Example 4 End -->
<!-- Example 5 Start - How to parse XML input with Xpath -->
<flow name="docs-greetingFlow5" doc:name="greetingFlow5">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="greet5" doc:name="HTTP"/>
<expression-component doc:name="Expression"><![CDATA[flowVars['username'] = xpath('/user/username').text]]></expression-component>
<set-payload value="#[xpath('/user/username').text], #[xpath('/user/age').text], #[xpath('/user/age').text > 18]" doc:name="Set Payload"/>
<file:outbound-endpoint path="Path_of_your_choice" responseTimeout="10000" doc:name="File"/>
<set-payload value="Hello #[flowVars['username']]" doc:name="Set Payload"/>
</flow>
<!-- Example 5 End -->
<!-- Example 6 Start - How to parse Java objects -->
<flow name="greetingFlow6" doc:name="greetingFlow6">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="greet6" doc:name="HTTP"/>
<json:json-to-object-transformer doc:name="JSON to Object" returnClass="java.lang.Object"/>
<expression-component doc:name="Expression"><![CDATA[flowVars['username'] = payload.username]]></expression-component>
<set-payload value="#[payload.username], #[payload.age], #[payload.age > 18]" doc:name="Set Payload"/>
<file:outbound-endpoint path="Path_of_your_choice" responseTimeout="10000" doc:name="File"/>
<set-payload value="Hello #[flowVars['username']]" doc:name="Set Payload"/>
</flow>
<!-- Example 6 End -->
</mule>