# Aggregator

> Collect related messages and merge them into one — the counterpart to Splitter.

- **Category**: Integration
- **Subcategory**: Message Routing
- **Canonical URL**: https://designpattern.fyi/patterns/aggregator/

---

## Description
Clean, reusable architecture pattern.


## Use Cases
Scatter-Gather price comparison — request sent to 5 supplier services. Each replies with a PriceQuote message sharing a requestCorrelationId. Aggregator waits for all 5 (or 10-second timeout), merges quotes into a PriceComparisonResult, emits to the requester. Best price wins.





## Trade-offs


### Advantages

- Reassembles split or scattered processing back into a coherent result

- Handles partial responses with timeout-based completion

- Correlation-based grouping works across async, distributed processing

- Essential counterpart to Splitter and Scatter-Gather




### Considerations & Drawbacks

- Buffer memory grows with in-flight messages — needs bounds and TTL

- Completion condition design is subtle — timeouts vs count-based vs signal-based

- Partial failures (one message never arrives) need explicit handling

- State management is complex in distributed, multi-node setups







---
**Reference**: [Original Source](https://www.enterpriseintegrationpatterns.com/patterns/messaging/Aggregator.html)

