Command Palette

Search for a command to run...

PHASE 11Intermediate ~6 min· topic 7 of 15

Topic 11.7

Asynchronous Communication (Kafka/Queue)

In one line

Fire events and let each service react: the decoupling engine behind microservices.

0/15 · 0%

Think of it like this

Dropping a note in someone's mailbox and continuing your day; they'll read and act on it whenever they get to it, and you don't have to stand there waiting.

Key ideas

  1. 01

    Event-driven: service A publishes OrderPlaced; services B, C react independently — no A knows them.

  2. 02

    Values: decoupling (add consumers freely), resilience (producer doesn't wait), buffering, replay (Kafka).

  3. 03

    Costs: eventual consistency (B may lag), debugging across hops, no synchronous error surface for the caller.

  4. 04

    Command vs event: commands tell (do X), events state (X happened) — events are the safer, replayable contract.

  5. 05

    Sagas/outbox (11.13/11.14) are the standard companions — async isn't 'free', it's 'differently paid'.

  6. 06

    Interview: 'order placement publishes OrderPlaced; inventory, billing, and notifications each subscribe — no fan-out code in the producer'.

Java / Spring map

  • →

    Spring Kafka producers/consumers; @TransactionalEventListener for outbox-safe publishing.

Explain without notes

01

The producer crashes after DB commit but before the event publish — which pattern makes this impossible (outbox)?

Practice

01

Model the order→{inventory, billing, events} fan-out with a Kafka topic and per-service consumer groups.

Trade-offs

  • ↔

    Great decoupling of scale, paid in consistency lag and a monitoring bill.

Run it in production

Completion checklist

  • I can sketch an event fan-out and name the outbox/saga companions.

Back to phase