The Real Fullstack

The Missing Event

The order is in the database. Why was it never shipped?

Ingénieur senior10 minSimulateur de fluxDéfi de code
kafkapostgresqlspring-bootdebeziumjava

Ce défi n'est pas encore traduit en Français. Vous lisez la version anglaise.

Mission:Reproduce the lost event, then make the database write and the event consistent under every combination of crashes, rollbacks, broker outages and relay restarts.Contexte · Objectifs d'apprentissage ▾

Brightcart's order service saves an order, then publishes OrderPlaced to Kafka for shipping. Every week a few orders are never shipped. They all coincide with deployments or short broker outages. An earlier attempt to publish inside the transaction created shipments for orders that didn't exist.

Mission: Reproduce the lost event, then make the database write and the event consistent under every combination of crashes, rollbacks, broker outages and relay restarts.

Objectifs d'apprentissage

  • Explain the dual-write problem between a database and a broker.
  • Implement the transactional outbox.
  • Pair at-least-once publishing with idempotent consumers.
SimulationSimulé
Order serviceOrders DBOutbox relayorders topicShipping
Lancer la simulation

Lancez la simulation pour voir la sortie.

Simplification

Four failure points; each happens at most once. Real relays also need ordering per aggregate and cleanup of sent rows. Modèle pédagogique — les chiffres illustrent un comportement, ce ne sont pas des benchmarks.

Concepts

Utile avant celui-ci

Défis liés

Références