Skip to content

ESDM — Samples

These are the samples for the ESDM — Event-Sourced DDD guide. See also Short info and the tutorial.

Use the conceptual flow ReserveSeat → SeatReserved → Availability projection.

  1. Start with capacity 2 and no reservations.
  2. Record SeatReserved for 1 seat; the projected remaining capacity becomes 1.
  3. Record a second successful reservation for 1 seat; the projected value becomes 0.
  4. Consider receiving the same event identifier again. State how the projection avoids counting it twice.

The example explains the intended projection and duplicate-handling obligation. An importer can check model references; a separate implementation test must exercise the replay behavior.

These four exercises are lesson briefs. Their dedicated CtxBazaar recipes and browser launch actions are planned; see Learning with models for available downloads and the meaning of each result.

Exercise Try this Expected observation
Reserve a seat Import a model with ReserveSeat, SeatReserved and a reservation aggregate. Distinguish a command that can be rejected from the fact recorded after success.
Availability projection Add a read model that derives available seats from reservation events. Explain what must be replayed to rebuild the view.
Retry and idempotency Describe duplicate delivery of the same reservation event. State the deduplication obligation without claiming import validation proves runtime behavior.
Compensating process Describe a payment failure after a seat reservation. Identify a compensating action and distinguish it from deleting the original event.