# Splitter

You receive a CSV with 5,000 orders. You could loop in your controller and call `commandBus->send()` 5,000 times — but the whole loop runs in one HTTP request, fails atomically, and one bad row blocks the rest. A **Splitter** takes the array as a Message and emits 5,000 individual Messages onto a downstream channel. Each row becomes its own retryable, individually-deduplicated unit of work.

Reach for a Splitter whenever the input is "one envelope, many work items" — bulk imports, fanning a webhook into per-line handlers, breaking up a daily report into per-customer jobs.

```php
class Shop
{
    #[Splitter(inputChannelName="buyProduct", outputChannelName="buySingleProduct")]
    public function sendMultipleOrders(array $products) : array
    {
        return $products;
    }

    #[ServiceActivator("buySingleProduct")] 
    public function buyProduct(string $productName) : void
    {
        echo "Product {$productName} was bought";
    }
}
```

### Possible options

* `endpointId` - Endpoint identifier
* `inputChannnelName` - Required option, defines to which channel endpoint should be connected
* `outputChannelName` - Channel where result of method invocation will be
* `requiredInterceptorNames` - List of [interceptor](/modelling/extending-messaging-middlewares/interceptors.md) names, which should intercept the endpoint


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ecotone.tech/messaging/messaging-concepts/message-endpoint/splitter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
