architecture decision

ADR-002: Use the transactional outbox for order events

Order lifecycle events are written to an outbox in the order database before being published to the domain event bus.

Decision RecordMarch 12, 2024AcceptedReliability

Context

Order events must be published reliably when the order write succeeds. Publishing directly from the request path creates a failure window where the database commit succeeds but event publication fails.

Decision

OrdersService will write order events to an outbox table in orders-db in the same transaction as the aggregate update. A background publisher reads the outbox and publishes to the orders domain event bus.

Consequences

The order write path remains consistent and event publication can be retried independently. Consumers must tolerate small publication delays and duplicate delivery.