# Resequencer

> Messages arrived out of order — buffer them and release in the correct sequence.

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

---

## Description
Clean, reusable architecture pattern.


## Use Cases
Financial transaction log replay — 1000 transaction messages are published in parallel but arrive out of order. Resequencer buffers and releases them in transaction-timestamp order. Downstream ledger receives events in the correct chronological order, maintaining balance integrity.





## Trade-offs


### Advantages

- Restores ordering guarantees that async delivery breaks

- Transparent to downstream processors — they see ordered messages

- Works without modifying producers or downstream consumers

- Pairs naturally with Message Sequence pattern




### Considerations & Drawbacks

- Buffering all out-of-order messages = memory pressure at high throughput

- A single missing message can block the entire sequence indefinitely

- Timeout strategy for missing messages must be tuned carefully

- Adds latency — messages wait in buffer until sequence is complete







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

