Messaging Patterns Workshop
Retrieval Prompts
- State the rule for choosing point-to-point vs publish-subscribe.
- Define event notification and event-carried state transfer in one sentence each.
- State the dual-write bug in one sentence.
- Explain the outbox pattern's core claim in one sentence.
- Name two legitimate variants of the outbox relay.
Compare and Distinguish
- point-to-point queue vs pub-sub topic (consumer count, work vs broadcast)
- SNS + SQS vs Kafka topic + consumer groups (how each realizes pub-sub)
- event notification vs ECST (callback vs self-contained payload)
- publish after commit vs outbox relay (race window, atomicity)
- outbox polling vs CDC log tailing (simplicity vs latency)
Common Mistake Check
For each, name the error and the correct alternative:
- "We use SQS standard to broadcast
OrderPlacedto three services, and we get duplicates, not broadcast." - "We have 20 subscribers on
user-signed-up, all doing 'send welcome email' with small variations." - "Our event carries the full user record, including the password hash."
- "We
INSERT INTO ordersthenkafka.produce(...)in the same Python function, and sometimes events go missing after a crash." - "We publish the event in the same thread as the HTTP response, so the customer sees the confirmation page faster."
- "We delete outbox rows immediately on successful publish to keep the table small."
- "Our outbox relay publishes, then updates
published_at, and sometimes we see duplicate events -- bug?"
Scenario Drills -- Pick the Pattern
For each scenario, pick and defend:
- queue or topic?
- notification or ECST?
- outbox required?
Scenario A -- Image upload and thumbnail generation
A user uploads an image. The system stores it in S3, then workers generate 4 thumbnail sizes. The product manager says it is fine if thumbnails are a second or two late.
Scenario B -- Order placement and downstream fan-out
A user places an order. Billing must charge, inventory must reserve, notifications must email, analytics must record. Billing is the only flow whose failure cancels the order.
Scenario C -- Background batch: send a nightly report
At 3 a.m., the system sends each customer a PDF of yesterday's transactions. 200k customers.
Scenario D -- Real-time fraud scoring as orders are placed
Scoring must happen before the order is fulfilled. The fraud service must return a decision within 200 ms to the checkout service.
Scenario E -- Customer profile update propagated to 6 systems
The user changes their email. The profile service updates; 6 downstream systems (marketing, support CRM, billing, analytics, access control, feature flags) all want the latest email.
Expected shape of answers:
- A: queue (work distribution); thumbnails; no outbox needed (workers are idempotent by URL).
- B: topic (broadcast) for
OrderPlaced; ECST for the payload (so consumers do not hammer checkout); outbox required on checkout. - C: task queue; ECST of the report summary; outbox not needed if emission is a scheduled job with idempotent send.
- D: synchronous request/reply (command with reply), not an event. This is not an EDA problem.
- E: topic; choose between ECST (ship the new email) and notification (consumers fetch). ECST often better here because the downstream systems want to keep running while the profile service is down.
Outbox Pattern Sketch
Design the outbox for a BookingService that creates a booking and emits BookingCreated. In 30 minutes:
1. DDL
Write the CREATE TABLE statements for:
bookings(primary entity)outbox(event buffer)
Include indexes that the relay will use.
2. The write transaction
Write the pseudocode (or real SQL) for the create_booking transaction that atomically inserts the booking and the outbox row.
3. The relay
Write the pseudocode for a polling relay:
- selects unpublished rows
FOR UPDATE SKIP LOCKED - publishes to the broker
- updates
published_at - handles publish failure
4. Consumer idempotency
Describe how a BillingService consuming BookingCreated dedupes by event_id. Pick the dedup store and TTL.
5. Operational questions
- What metrics do you emit about the outbox?
- What alert threshold triggers pager?
- How do you archive the outbox table?
Notification vs ECST Rewrite
Take this thin event:
{ "event_type": "OrderPlaced", "order_id": "ord_9f2a", "occurred_at": "..." }
And:
- Identify three plausible consumers.
- For each, decide whether it prefers notification or ECST.
- If ≥2 want ECST, write the ECST payload.
- Decide which fields are sensitive (PII, secrets) and keep them off the event.
Evidence Check
This page is complete only when:
- You answered the 5 scenario drills with pattern + reason.
- You produced a runnable-looking outbox sketch (DDL, write txn, relay, consumer dedup).
- You rewrote the thin
OrderPlacedevent as both notification and ECST, and you can explain when to pick which. - You can state the dual-write bug and the outbox fix in your own words, without looking.