Skip to main content
PreparationZone Logo
PrepZone

Ordering, Causality, and Partition Strategy

Design partition keys so causally related VaultCommerce events always land on the same partition.

Pass checkpoint below

Why this matters

  • PaymentCaptured must not be processed before OrderPlaced — same orderId key ensures order.
  • Cross-aggregate causality (parent order → child returns) needs careful key design.
  • Headers can carry correlationId for tracing but not for ordering guarantees.
  • Expert topic tying partitioning, sagas, and stream joins together.
At-most-once
Fire and forgetNo retry
Risk: loss
At-least-once
Retry on failureKafka default
Risk: duplicates
Exactly-once
Transactions + idempotence
Cost: complexity
At-most-once may lose messages. At-least-once may duplicate. Exactly-once needs broker and application cooperation.

Partition key as causality boundary

All events for order-42 use key order-42 on all topics in the saga. VaultCommerce enforces via shared EventPublisher wrapper that rejects publishes without key. Different orders interleave freely across partitions.

Key points

  • Causality — event A must be observed before dependent event B
  • Correlation ID — tracing across services; does not enforce order
  • Partition key scope — ordering guarantee boundary
  • Cross-topic ordering — not guaranteed; design per-saga keys
  • Event versioning — ignore stale events with lower version numbers

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 2 sections

  • Cross-topic ordering limits
  • VaultCommerce rollout checklist

Test yourself

Answer these before moving on — recall is what makes it stick.