---
title: Split
description: Learn how to use EIPs
documentId: ipaas-eips-split
locale: en-US
---

The **Split** EIP allows you to divide messages that contain multiple elements (such as lists, *arrays*, XML/JSON files, or multi-line texts) into smaller parts.
Each item is processed individually within a flow, facilitating the handling of complex messages.

**When to use Split?**

* To process each record of a JSON file separately.
* To iterate through elements of a list and apply rules to each one.
* To analyze line by line in structured text.

## Parameters

| Parameter | Description | Default value | Type |
|-----------|-----------|--------------|------|
| Expression | Defines how the input message should be split into smaller parts. | | ExpressionDefinition |
| AggregationStrategy | Defines how the results of the split messages will be combined back into a single message at the end of processing. | | AggregationStrategy |

## Aggregation strategies

An aggregation strategy (**Aggregation Strategy**) is the method used to rejoin the results that were processed individually after the message split.

<Callout type="important" title="IMPORTANT">

* **Most used aggregation strategy**: *GroupedBodyAggregationStrategy* (joins the *bodies* of messages into a list).
* Configuration in the **Aggregation Strategy** field: *#class:org.apache.camel.processor.aggregate.GroupedBodyAggregationStrategy*.
</Callout>

Check one by one the aggregation strategies you can use in **Sensedia Integrations**:

* `GroupedBodyAggregationStrategy`: one of the most useful. Groups only the body (*body*) of incoming messages into a `java.util.List`. Simple and efficient for collecting results.

* `GroupedExchangeAggregationStrategy`: similar to the previous one, but instead of grouping only the bodies, it groups the complete *Exchange* object (with headers, properties, etc.) into a `java.util.List`.

* `UseLatestAggregationStrategy`: discards the previous aggregated message and always keeps the most recent one. Useful when only the last result of a process matters.

* `UseOriginalAggregationStrategy`: discards the new message and always keeps the original one (the first one that started the aggregation). This is the default behavior of the Multicast EIP.

* `StringAggregationStrategy`: a simple strategy that concatenates the message bodies (converted to *string*) into a single *string*, usually separated by a newline character.

## Example

```yaml
- from:
    uri: rest:post:/process
    steps:
      - split:
          expression:
            simple:
              expression: ${body.split(',')}
          aggregationStrategy: "#class:org.apache.camel.processor.aggregate.GroupedBodyAggregationStrategy"
      - log:
          message: "Processing order: ${body}"
```

* The flow is initiated by a **POST** request sent to the `/process` *endpoint*.

* The request body must contain a list of order IDs separated by commas, for example:
  `1001,1002,1003`.

* The **Split** EIP divides this list into individual elements, and each ID is processed separately in the *log*:

  * `Processing order: 1001`
  * `Processing order: 1002`
  * `Processing order: 1003`

* Finally, the `GroupedBodyAggregationStrategy` brings together all the processed items again into a single list.
