How to use splitter component

8
How to use Splitter Component 21-12-2014

Transcript of How to use splitter component

Page 1: How to use splitter component

How to use Splitter Component

21-12-2014

Page 2: How to use splitter component

Abstract

• The main motto of this PPT is How to use Splitter Component in our applications.

Page 3: How to use splitter component

Introduction• The Splitter Flow Control splits a message into separate fragments, then

sends these fragments one at a time to the next message processor in the flow. Segments are identified based on an expression parameter, usually written in Mule Expression Language (MEL), but other formats can be employed also. You can then use aCollection Aggregator Flow Control to reassemble the parts of the original message. You can also include a Resequencer Flow Control to put the parts back into the original sequence in case they are shuffled out of order.

• Splitting and aggregating the message is especially useful when you intend to process the split parts in asynchronous flows running on separate servers. Together, the splitter and aggregator flow controls allow you to share the workload among several servers and still be able to reassemble the message after it’s processed.

Page 4: How to use splitter component

Example

Page 5: How to use splitter component

.mflow• <?xml version="1.0" encoding="UTF-8"?>

• <mule 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" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="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• http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">• <flow name="SplitterPOCFlow1" doc:name="SplitterPOCFlow1">• <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8089" path="SplitterPOC"

doc:name="HTTP"/>• <logger message="--Entered into the flow" level="INFO" doc:name="Logger"/>• <set-payload value="&lt;shiporder xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;

orderid=&quot;555-66-7777&quot;&gt; &lt;orderperson&gt;Derek Adams&lt;/orderperson&gt; &lt;shipto&gt; &lt;name&gt;Azaz Desai&lt;/name&gt; &lt;address&gt;123 Test Drive&lt;/address&gt; &lt;city&gt;Ahmedabad&lt;/city&gt; &lt;country&gt;India&lt;/country&gt; &lt;/shipto&gt; &lt;item&gt; &lt;title&gt;Laptop&lt;/title&gt; &lt;note&gt;Some piece of Mac crap!&lt;/note&gt; &lt;quantity&gt;1&lt;/quantity&gt; &lt;price&gt;99.97&lt;/price&gt; &lt;/item&gt; &lt;item&gt; &lt;title&gt;Memory Chips&lt;/title&gt; &lt;note&gt;1 GB&lt;/note&gt; &lt;quantity&gt;4&lt;/quantity&gt; &lt;price&gt;49.99&lt;/price&gt; &lt;/item&gt; &lt;/shiporder&gt;" doc:name="Set Payload"/>

• <splitter enableCorrelation="ALWAYS" expression="#[xpath:shiporder/item/title]" doc:name="Splitter"/>• <logger message="--After Splitter #[payload]" level="INFO" doc:name="Logger"/>• </flow>• </mule>

Page 6: How to use splitter component

• Output:INFO 2015-12-21 11:23:06,695 [[SplitterPOC].config.change.2.thread.1] org.mule.DefaultMuleContext: *********************************************************************** Application: SplitterPOC ** OS encoding: Cp1252, Mule encoding: UTF-8 ** ** Agents Running: ** Clustering Agent ** JMX Agent ***********************************************************************INFO 2015-12-21 11:23:06,696 [[SplitterPOC].config.change.2.thread.1] org.mule.module.launcher.MuleDeploymentService: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Started app 'SplitterPOC' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++INFO 2015-12-21 11:23:13,044 [[SplitterPOC].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: --Entered into the flowINFO 2015-12-21 11:23:13,124 [[SplitterPOC].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: --After Splitter LaptopINFO 2015-12-21 11:23:13,127 [[SplitterPOC].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: --After Splitter Memory Chips

Page 7: How to use splitter component

• Flow of execution:1. URL to trigger the service from browserhttp://localhost:8089/SplitterPOC 2.Splitter component splits the input request based on the given expression and displays the results in Console.