Skip to main content

Employee Event Idempotency and Ordering

Summary

Duplicate handling is consumer-owned and differs by service. No global exactly-once or total-order guarantee is implemented in the reviewed source.

Audience

  • Consumer developers, QA engineers, and architects

Overview

The outbox has a unique event identifier and selects messages by occurrence time, but distributed publication and redelivery can still produce duplicates or observable reordering. Consumers therefore implement local controls.

Confirmed patterns

  • Leave stores the last profile event identifier and occurrence time on its projection. It records and ignores a repeated identifier and ignores an event older than its last applied event.
  • Payroll checks a processed-integration-event store before applying a delivery and records successful processing.
  • Document Service implements its own event-processing state for subscribed Employee profile updates.
  • Integration Service defines a unique processed-event record and a duplicate audit stage.
  • A uniform platform-wide idempotency library is Not implemented in the reviewed consumer code.

Idempotent consumer pattern

Not every inspected consumer exposes both checks. The diagram is a composite of confirmed patterns, not a claim that every consumer follows every branch.

Ordering boundaries

Employee outbox retrieval orders eligible rows by their occurrence timestamp. Consumers use single-message prefetch in the inspected direct broker consumers. Neither mechanism proves global ordering across retries, consumer restarts, or multiple event types. Consumers should use event identity and, where available, an occurrence-time watermark rather than relying solely on arrival order.

Source References

  • microservices/src/employee-service/Infrastructure/Persistence.cs
  • microservices/src/leave-service/Messaging/EmployeeProfileConsumer.cs
  • microservices/src/payroll-service/Messaging/PayrollReadModelConsumer.cs
  • microservices/src/document-service/Messaging/DocumentReadModelConsumer.cs
  • microservices/src/integration-service/Domain/IntegrationEntities.cs

See Also

Keywords

  • Duplicate suppression
  • Event ordering
  • Projection watermark

Revision Information

  • Status: Draft
  • Last reviewed: 2026-07-15
  • Review cycle: Quarterly