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 6-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”
When you check a bag at the airport, the agent attaches a tag listing every leg of the journey: Dallas to Chicago, Chicago to London, London to Mumbai. At each airport, handlers read the tag, put the bag on the next flight, and check off the current leg. The bag carries its own routing instructions.
A routing slip works the same way for messages. Instead of a central process manager deciding where each message goes next, the routing instructions are attached to the message itself. Each service in the pipeline reads the slip, processes the message, checks off its step, and forwards the message to the next service on the list.
The key difference from a process manager: there's no central coordinator. The intelligence is in the message, not in an external component. Each service is independently responsible for forwarding to the next step. This makes the pattern lightweight and decentralized.
The message carries a list of processing steps. Each service removes itself from the list and forwards the message to the next entry:
// Initial message with routing slip
{
payload: { orderId: "123", items: [...] },
routingSlip: [
"service:validation",
"service:fraud-check",
"service:payment",
"service:fulfillment",
"service:notification"
],
currentStep: 0,
results: {}
}
Each service:
results fieldcurrentStepasync function processAndForward(msg: RoutingSlipMessage) {
// Process this step
const result = await processLocally(msg.payload);
// Record result
msg.results[msg.routingSlip[msg.currentStep]] = result;
msg.currentStep++;
// Forward to next step (or complete if done)
if (msg.currentStep < msg.routingSlip.length) {
const nextService = msg.routingSlip[msg.currentStep];
await queue.publish(nextService, msg);
} else {
await queue.publish('pipeline-complete', msg);
}
}
Dynamic routing slips. The slip can be modified during processing. The validation service might add a "manual-review" step if the order looks suspicious. The fraud-check service might remove the payment step if the order is pre-paid. The pipeline adapts at runtime.