# Message Sequence

**In short:** Message Sequence splits data that is too big for one message into several smaller messages. Each message carries a position, so the receiver can put the parts back in order and rebuild the whole.

## Explanation

Sometimes an application must send more data than fits in a single message. Messaging systems often limit message size, and large messages can also slow the system down. Message Sequence is one way to handle this.

The idea is simple. The sender cuts the data into parts and sends each part as its own message. Every message carries a position identifier. That identifier uniquely identifies the message and fixes its place in the order.

**Putting the parts back together**

Two related patterns help the receiver:

- The Aggregator receives a stream of messages, finds the ones that belong together (see Correlation Identifier) and combines them.
- The Resequencer receives a stream that may arrive out of order. It holds early arrivals in an internal buffer. When a complete sequence is available, it publishes the messages in order.

**Missing parts**

A part may never arrive. One completeness strategy is to wait for all parts. Another is a timeout: wait a fixed time, then proceed with what arrived. Which one fits depends on whether a partial result is useful.

**Alternative: Claim Check**

The Claim Check pattern stores the full payload in an external data store. Only a reference travels through the messaging system.

## Example

An export job produces a very large report, and the channel accepts only small messages. The sender cuts the report into numbered chunks and sends them all. The receiver buffers the chunks, joins them in order and hands over the complete report. If a chunk does not arrive before the timeout, the receiver follows its chosen rule for missing parts.

## Trade-offs

Splitting keeps the data inside the messaging system. The price is extra design work: sequencing, correlation, duplicate handling and reassembly.

Claim Check avoids that work. It adds extra network trips compared with sending the data inline. It also makes the system depend on an external store.

A large payload is split into numbered parts, sent through a channel and rebuilt by the receiver.

```mermaid
flowchart LR
  S[Sender] -->|split| M1[Part 1]
  S --> M2[Part 2]
  S --> M3[Part 3]
  M1 --> C[Channel]
  M2 --> C
  M3 --> C
  C --> R[Resequencer and Aggregator]
  R -->|rebuild| O[Original data]
```

## Checks

- The document names the message size limit that makes splitting necessary.
- Each message in a sequence carries a position identifier that orders it.
- The design states how out-of-order arrivals are buffered and reordered before processing.
- The design states what happens when parts are missing, such as waiting for all parts or a timeout.
- The design explains why Message Sequence was chosen over Claim Check, including duplicate handling and reassembly effort.

## Related

- [Claim Check](https://arc.fuet.ch/concepts/integration/claim-check.md)
- [Correlation Identifier](https://arc.fuet.ch/concepts/integration/correlation-identifier.md)
- [Message Channel](https://arc.fuet.ch/concepts/integration/message-channel.md)
- [Messaging](https://arc.fuet.ch/concepts/integration/messaging.md)
- [Composed Message Processor](https://arc.fuet.ch/concepts/integration/composite-message-processor.md)
- [Idempotent Receiver](https://arc.fuet.ch/concepts/integration/idempotent-receiver.md)
- [Message Structure](https://arc.fuet.ch/concepts/integration/message-structure.md)
- [Enterprise Integration Patterns](https://arc.fuet.ch/concepts/integration/messaging-pattern-language.md)

## Sources

- [Message Sequence - Enterprise Integration Patterns](https://www.enterpriseintegrationpatterns.com/patterns/messaging/MessageSequence.html) — enterpriseintegrationpatterns.com, accessed 2026-11-09
- [Resequencer - Enterprise Integration Patterns](https://www.enterpriseintegrationpatterns.com/patterns/messaging/Resequencer.html) — enterpriseintegrationpatterns.com, accessed 2026-11-09
- [Aggregator - Enterprise Integration Patterns](https://www.enterpriseintegrationpatterns.com/patterns/messaging/Aggregator.html) — enterpriseintegrationpatterns.com, accessed 2026-11-09
- [Claim Check pattern - Azure Architecture Center | Microsoft Learn](https://learn.microsoft.com/en-us/azure/architecture/patterns/claim-check) — learn.microsoft.com, accessed 2026-11-09
