We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
System Design Masterclass · Messaging Event Systems
Free preview: the first 2 parts of this 7-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Messaging Event Systems
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
In a large corporation's mail room, someone opens each piece of mail, reads the subject, and routes it to the right department. Tax documents go to finance. Resumes go to HR. Customer complaints go to support. The routing decision depends entirely on the content of the message.
Content-based routing works the same way in messaging. Instead of every message going to the same queue or consumer, a router inspects each message's content and forwards it to the appropriate destination.
An e-commerce platform receives order events. Domestic orders go to the domestic fulfillment queue. International orders go to the international fulfillment queue. High-value orders (over $1,000) go to a fraud review queue. The routing logic inspects the order's destination country and total amount to decide where each message goes.
This is one of the foundational Enterprise Integration Patterns (EIP), described by Gregor Hohpe and Bobby Woolf in their 2003 book. Nearly every message-driven system uses some form of content-based routing, whether they call it that or not. AWS EventBridge is a managed content-based router at its core: events arrive, rules evaluate them, and matching events route to targets. Azure Service Bus topic subscriptions with filters do the same thing. Every enterprise messaging system has this pattern built into the broker or implemented as a service.
A content-based router sits between the source and multiple destinations. It inspects message attributes or payload and applies routing rules:
function routeOrder(message: OrderEvent) {
if (message.country !== 'US') {
return 'queue:international-fulfillment';
}
if (message.totalAmount > 1000) {
return 'queue:fraud-review';
}
if (message.isPriority) {
return 'queue:express-fulfillment';
}
return 'queue:standard-fulfillment';
}
Implementation approaches across brokers:
| System | Mechanism | Where Rules Live |
|---|---|---|
| RabbitMQ | Topic exchange with routing keys, or headers exchange | In exchange bindings (broker-native) |
| Kafka Streams with conditional branching | In application code | |
| AWS | SNS filter policies, EventBridge rules | In AWS console or IaC templates |
| Azure | Service Bus topic subscriptions with filters | In subscription rules (broker-native) |
| Custom | Router service that reads from one queue and publishes to others | In your code |
RabbitMQ topic exchange example:
Producer publishes to exchange "orders" with routing key "orders.US.standard"
Subscription "domestic" binds with pattern "orders.US.*" -> matches
Subscription "intl" binds with pattern "orders.EU.*" -> no match
Subscription "express" binds with pattern "orders.*.express" -> no match
The broker evaluates routing patterns without custom code. This is the most efficient form of content-based routing because the broker is already parsing the message metadata. No additional service, no additional hop, no additional .
AWS EventBridge rules example:
{
"source": ["orders.service"],
"detail-type": ["OrderCreated"],
"detail": {
"country": ["US"],
"amount": [{"numeric": [">", 1000]}]
}
}
EventBridge evaluates this rule against every event. Matching events route to the configured target (Lambda, SQS, Step Functions). No custom router service needed.