# Correlation Identifier

> Tag every request with a unique ID so you can match its reply later.

- **Category**: Integration
- **Subcategory**: Message Construction
- **Canonical URL**: https://designpattern.fyi/patterns/correlation_identifier/

---

## Description
Clean, reusable architecture pattern.


## Use Cases
API gateway sends 100 concurrent PriceCheck requests to a pricing service. Each has a unique correlationId. Replies arrive out of order (async). Gateway matches each reply to the waiting HTTP request via correlationId map. All 100 responses correctly delivered.





## Trade-offs


### Advantages

- Essential for concurrent async request-reply flows

- Enables out-of-order reply matching

- Works across multiple reply channels and partitions

- Standard pattern — supported natively in most broker headers




### Considerations & Drawbacks

- Requires unique ID generation (UUID — cheap but needs to be truly unique)

- In-memory correlation map leaks if replies never arrive — needs TTL/cleanup

- Adds overhead to every message

- IDs must be propagated correctly through every hop (easy to lose in complex pipelines)







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

