---
id: flow--scatter
title: "Scatter"
summary: "First half of the scatter-gather pattern: sends the same input message to every component connected to `Output`, in parallel, and tags each copy so that a **Gather** component can later combine the branch results into one message."
audience: user
keywords: "input, output, timeout"
---
# Scatter

First half of the scatter-gather pattern: sends the same input message to every component connected to `Output`, in parallel, and tags each copy so that a **Gather** component can later combine the branch results into one message.

## Pins

| Pin | Kind | Types | Description |
|---|---|---|---|
| Input | input | any | The message to distribute. |
| Output | output | same as input | One copy of the input per output connection (branch). |

## Configuration

| Field | Type | Default | Description |
|---|---|---|---|
| `Timeout` | integer (seconds, >= 0) | `0` | Maximum time for all branches to reach the Gather component. `0` = wait indefinitely. |

## Behaviour

- For every input, each connection on `Output` is one *slot*. The input is sent to all connections at the same time (each on its own task), with a copy of the metadata that carries the scatter information (`Viaducta.Plugins.ScatterGather.Types.ScatterMetaData`: slot id = connection id, plus a shared handler).
- The component waits until all branches have finished their processing before it completes.
- Gather emits the combined result when every slot has received one result.
- With `Timeout` > 0, a background check runs every second: if not all slots were filled in time, a recoverable timeout error ("The timeout occurred while waiting for gatherer to collect all of the inputs") is raised to the flow's error handling with the original input, and Gather ignores late results for that message.
- With no output connection nothing happens.

## Notes

- Every branch must deliver exactly **one** message to Gather per input. A branch that filters the message out (or fails) leaves its slot empty, and Gather never emits - use `Timeout` to detect this. A branch that emits several messages fills the counter more than once.
- Each branch must end in a different component connected to Gather; Gather names its output properties after these components.
- The branch connections from `Output` should all lead (possibly through other components) to the same Gather.
- Very fast branches can finish before Scatter has registered all slots; in that case Gather may never complete. Set a `Timeout` in production flows.

## Example

```json
{ "Timeout": 30 }
```

Http listener → **Scatter** → (Http client "PriceService", Database reader "StockService") → Gather (`OutputName` = `ProductInfo`) → Http response
