Messaging fundamentals
On this page 8 topics
Overview
Topics
- Queues
- topics
- producers
- consumers
- delivery semantics
Learn first
2 h of practice (estimate)
Learning outcomes
- Distinguish queues (point-to-point) from topics (publish/subscribe).
- Distinguish commands from events and name events in the past tense.
- Explain at-most-once, at-least-once, and effectively-once delivery, and why exactly-once delivery is not available end to end.
- Design an event payload (identity, timestamp, version, minimal vs full state).
Lessons
Lab and exercises
Lab
MID-026-LAB1 · Event catalog
Outcomes: 1–4 · Time: ~2 h
- List Shop's business events:
OrderPlaced,StockReserved,StockReservationFailed,PaymentAuthorized,PaymentFailed,OrderCancelled, and others you find. - For each give: owner service, past-tense name, schema (fields and types), version, key, consumers.
- Mark which messages are commands, and keep them out of the event list.
- Have a peer review the catalog.
Acceptance: reviewed catalog used by later labs.
Exercises (assessment: quiz plus catalog review; five exercises)
| ID | Outcome | Task |
|---|---|---|
| MID-026-EX01 | 1 | For notification emails, work distribution to image resizers, and order events, choose queue or topic and justify. |
| MID-026-EX02 | 2 | Classify and rename if needed: SendEmail, OrderShippedEvent, UpdateInventoryNow, PriceChanged. |
| MID-026-EX03 | 3 | Explain why exactly-once delivery is not available end to end, using a lost-ack timeline. |
| MID-026-EX04 | 3 | Write idempotent handling for PaymentAuthorized using the eventId. |
| MID-026-EX05 | 4 | Design OrderPlaced payloads in minimal and full-state versions and compare them. |
Show solutions
- EX01 Emails and resizers: queue (competing consumers). Order events: topic (several independent subscribers).
- EX02
SendEmailcommand;OrderShippedEventevent (name asOrderShipped);UpdateInventoryNowcommand;PriceChangedevent. - EX03 Consumer processes and acks, but the ack is lost; the broker redelivers. The broker cannot know whether processing happened.
- EX04 Store processed
eventIds in a table with a unique constraint, in the same transaction as the effect; on duplicate key skip. - EX05 Minimal:
{eventId, orderId}, consumers callordersback (coupling, load). Full: includes lines and totals (autonomous consumers, bigger, schema must be versioned).
Quiz
Outcomes: O1 queues and topics · O2 commands and events · O3 delivery semantics · O4 event payloads.
A self-check for you: nothing is graded, saved or sent anywhere. Choose an answer, then check it. You can try again as often as you like.
Practical part
Five exercises MID-026-EX01 to EX05 plus the lab. Pass: at least four exercises correct and a peer-reviewed event catalog with owners, past-tense names, schemas, and versions.
Common mistakes
Events that are commands in disguise; events carrying entire database rows.
Assessment
Quiz plus catalog review.
Career relevance
Event-driven architecture (SRB-002).