What does the sequence number on a stored event guarantee?
Each event stored for an aggregate carries a sequence number — 0, 1, 2, and so on — that records its exact position in that aggregate's history. Axon stores and retrieves events strictly by this sequence, which guarantees that replaying an aggregate's history always processes its events in the exact order they truly happened, and therefore always rebuilds the same, correct final state. This holds even if multiple commands raced against the same aggregate concurrently, because the sequence numbers still resolve into one strict, final order at the moment events are persisted. Without this guarantee, replay would be non-deterministic, and the same event history could rebuild different final states on different runs.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response