Skip to content
Ameen Abozaid
MID-026

Messaging fundamentals

  • 6 Lessons
  • 2 h practice (estimate)
On this page 8 topics

Overview

Topics

  • Queues
  • topics
  • producers
  • consumers
  • delivery semantics

Learn first

2 h of practice (estimate)

Learning outcomes

  1. Distinguish queues (point-to-point) from topics (publish/subscribe).
  2. Distinguish commands from events and name events in the past tense.
  3. Explain at-most-once, at-least-once, and effectively-once delivery, and why exactly-once delivery is not available end to end.
  4. Design an event payload (identity, timestamp, version, minimal vs full state).

Lessons

  1. 01Why messaging
  2. 02Queues vs topics
  3. 03Commands vs events
  4. 04Delivery semantics
  5. 05Designing event payloads
  6. 06Demo: one event, three consumers

Lab and exercises

Lab

MID-026-LAB1 · Event catalog

Outcomes: 1–4 · Time: ~2 h

  1. List Shop's business events: OrderPlaced, StockReserved, StockReservationFailed, PaymentAuthorized, PaymentFailed, OrderCancelled, and others you find.
  2. For each give: owner service, past-tense name, schema (fields and types), version, key, consumers.
  3. Mark which messages are commands, and keep them out of the event list.
  4. Have a peer review the catalog.

Acceptance: reviewed catalog used by later labs.

Exercises (assessment: quiz plus catalog review; five exercises)

IDOutcomeTask
MID-026-EX011For notification emails, work distribution to image resizers, and order events, choose queue or topic and justify.
MID-026-EX022Classify and rename if needed: SendEmail, OrderShippedEvent, UpdateInventoryNow, PriceChanged.
MID-026-EX033Explain why exactly-once delivery is not available end to end, using a lost-ack timeline.
MID-026-EX043Write idempotent handling for PaymentAuthorized using the eventId.
MID-026-EX054Design 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 SendEmail command; OrderShippedEvent event (name as OrderShipped); UpdateInventoryNow command; PriceChanged event.
  • 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 call orders back (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.

  1. 1In a queue with competing consumers, each message is delivered to:O1
  2. 2Which model fits "notify all interested services"?O1
  3. 3Which name is a well-formed event?O2
  4. 4A command differs from an event because it:O2
  5. 5OrderPlacedPleaseReserveStock is a:O2
  6. 6At-least-once delivery means:O3
  7. 7Why is end-to-end exactly-once delivery unavailable?O3
  8. 8Effectively-once is achieved by:O3
  9. 9The eventId is used mainly for:O4
  10. 10A common payload mistake:O4

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).

Type to search levels, phases, modules and lessons.