The main purpose of the Split component is to split single messages into multiple messages based on a configured expression. The split messages are sent to the endpoint at the bottom of the component so they can be enriched. If some components are connected to the right endpoint of the split component, then the splitted messages will be aggregated back to one single message after they are enriched via the components connected to the bottom of the split component. This aggregated message will be sent to the components that are connected to the right endpoint of the split component.
The Split component has the following configuration options:
|/||The expression that defines how to split messages.|
|The language of the expression. Expressions can be defined using the Simple Expression Language, XPath 2.0, JSONPath or as tokens.|
|/||The prefix of the namespace that is used in the XML.|
|/||The namespace that is used in the XML.|
|The type of messages you want to aggregate. For now only JSON and XML are supported.|
|Split the input message in chunks to reduce memory overhead (used when dealing with large file sizes).|
|Input Message||Expression||Type||Output Messages|
|Collection of Java objects||Simple||One message for each object|
Splitting messages using the given Simple expression can be useful if you've constructed a message containing a collection of Java objects using the Script component.
Split component without aggregation
The message will be splitted into multiple messages following the expression and every message will be sent to the HTTP component.
Split component with aggregation.
Just like the example above the splitted messages will be sent to the endpoint at the bottom of the splitter. In this example the splitter has a connection on its right endpoint, so it wil aggregate the enriched splitted messages into one message and sent it to the remaining components in the flow that are connected to the right endpoint.
Filter component in the bottom route
It is possible that side effects occur in the case that a filter component is
used in the bottom route of the split component when the aggregation setting is
true. If the conditions of the filter component are not met, the original
message will be returned by the filter component to the split component.
The message body that is processed by the split component:
<orders> <order> <ordernr>1</ordernr> </order> <order> <ordernr>2</ordernr> </order> </orders>
This message will be split by this xpath expression:
The filter component contains the following xpath expression:
/order/ordernr/text() != '1'
The velcocity component after the split component contains this message body:
<orderNew> <ordernr>New</ordernr> </orderNew>
The aggregated message that comes out of the split component:
<Aggregated> <order> <ordernr>1</ordernr> </order> <orderNew> <ordernr>New</ordernr> </orderNew> </Aggregated>
This output could be unexpected because it contains a part of the original message
body, but there is an alternative solution. Instead of the
filter component you can use a
content router component with the same xpath
expression and a velocity component in the
otherwise route with this content:
The input is similar to the first case, the response of the flow is as follows:
<Aggregated> <orderNew/> <orderNew> <ordernr>New</ordernr> </orderNew> </Aggregated>