Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
bhalchandraswcg
Contributor

Previous - Recipient List | Index | Next - Aggregator


This week, we'll learn yet another Message Router known as Splitter.

When do I use this pattern?


This pattern is applied when the message is divided into parts and each part is sent to an interested receiver. For example, an order contains one or many order items. Individual order items may be delivered by different delivery systems.

There are two types of splitters:

  • Iterating Splitter that iterates over items and splits individual items into the separate message

  • Static Splitter that splits items into individual messages but keeps the outer elements.


Splitter in CPI


In CPI, Iterating Splitter is implemented using Iterating Splitter component, whereas, Static Splitter is implemented using General Splitter component.

To demonstrate, I'll split this sample payload using the splitter components:
<Order>
<Id>101</Id>
<OrderItem>
<Id>301</Id>
<ProductId>901</ProductId>
</OrderItem>
<OrderItem>
<Id>302</Id>
<ProductId>902</ProductId>
</OrderItem>
</Order>

Iterating Splitter


Integration Flow



Here, the integration flow starts as soon as it is deployed, sets the input payload using Content Modifier in Set Body step, splits the message using Iterating Splitter and Logs the output.

This is the configuration of Iterating Splitter:































Parameter Value
Expression Type XPath
XPath Expression /Order/OrderItem
Grouping
Streaming Yes
Parallel Processing No
Stop on Exception Yes

Output


<OrderItem>
<Id>301</Id>
<ProductId>901</ProductId>
</OrderItem>

<OrderItem>
<Id>302</Id>
<ProductId>902</ProductId>
</OrderItem>

As seen in the output, each order item is put in a separate message. Also, note that the outer elements have been skipped here. So, it will be impossible to identify which order these items belong to based on the payload alone.

Static Splitter


Integration Flow



Similar to Iterating Splitter flow, the integration flow starts as soon as it is deployed, sets the input payload using Content Modifier in Set Body step, splits the message using General Splitter and Logs the output.

This is the configuration of General Splitter:































Parameter Value
Expression Type XPath
XPath Expression /Order/OrderItem
Grouping
Streaming Yes
Parallel Processing No
Stop on Exception Yes

Output


<Order>
<Id>101</Id>
<OrderItem>
<Id>301</Id>
<ProductId>901</ProductId>
</OrderItem>
</Order>

<Order>
<Id>101</Id>
<OrderItem>
<Id>302</Id>
<ProductId>902</ProductId>
</OrderItem>
</Order>

Similar to the iterating splitter, each order item is put in a separate message. However, the outer elements have been kept here. So, it is possible to identify which order these items belong to based on the payload alone.

Conclusion


Splitter pattern is used to split the input message into multiple messages so that each new message can be sent to an interested receiver. In CPI, Splitter pattern is applied using Iterating Splitter and General Splitter components.

References/Further Readings



Hope this helps,
Bala

Previous - Recipient List | Index | Next - Aggregator

Labels in this area