Split component
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.
Configuration
The Split component has the following configuration options:
Property | Default | Description |
---|---|---|
Expression | / | The expression that defines how to split messages. |
Type | Simple | The language of the expression. Expressions can be defined using the Simple Expression Language, XPath 2.0, JSONPath or as tokens. |
Namespace prefix | / | The prefix of the namespace that is used in the XML. |
Namespace | / | The namespace that is used in the XML. |
Aggregation | None | The type of messages you want to aggregate. For now only JSON and XML are supported. |
Use Streaming | None | Split the input message in chunks to reduce memory overhead (used when dealing with large file sizes). |
Split Parallel | No | Split each message concurrently. Note the caller thread will still wait until all messages have been fully processed before it continues. It's only processing the sub-messages from the splitter which happens concurrently. |
Remarks
- On
Split Parallel
: Enabling this option may cause a severe increase of system usage, such as CPU, as everything happens concurrently. We do not reccomend to enable this option when splitting large files.
Examples
Input Message | Expression | Type | Output Messages |
---|---|---|---|
Collection of Java objects | ${bodyAs(String)} | Simple | One message for each object |
<bookstore><book title="one"/><book title="two"/></bookstore> | //book | XPath | <book title="one"/> and <book title="two"/> |
one@two@three | '@' | Tokenizer | one , two , and three |
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.
Example
The message body that is processed by the split component:
<?xml version="1.0" encoding="utf-8"?>
<orders>
<order>
<ordernr>1</ordernr>
</order>
<order>
<ordernr>2</ordernr>
</order>
</orders>
This message will be split by this xpath expression: //order
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:
<orderNew/>
.
The input is similar to the first case, the response of the flow is as follows:
<Aggregated>
<orderNew/>
<orderNew>
<ordernr>New</ordernr>
</orderNew>
</Aggregated>