What it is
A content based router is a message router that chooses a destination by examining the content of each message: its body, type, or fields. It sends orders, claims, or events to the handler that matches their data.
How it works
- The router reads fields such as a type code or region.
- It evaluates rules against those fields.
- It forwards the message to the channel for the matching rule.
Why it matters
- Senders need no knowledge of which service handles which case.
- New destinations are added by adding a rule, not editing producers.
- It handles heterogeneous message streams cleanly.
The main risk is coupling to message structure. If the router reads internal fields, a change to the payload may break routing. Teams often route on stable headers or a small set of fields to limit this. Heavy content inspection can also slow the router, so keep the rules cheap.
Key idea
A content based router inspects message content and forwards each message to the destination matching its data.