Superseded by 0078: the messaging layer is eight
packages with SaaS and self-hosted drivers; the outbox, idempotent-consumer and versioned-name
rules carry forward there.
Context
Services communicate by events (0010). Publishing after a database commit can lose or duplicate an event if the process fails between the two; Pub/Sub delivers at least once.Decision
- Events use Encore Pub/Sub; scheduled work uses Encore cron.
- Publishing goes through a transactional outbox: the event row is written in the same transaction as the state change, and a relay publishes it.
- Every consumer is idempotent, deduplicating on the event id.
- Events are versioned by name (
user.created.v1) and their shapes live in contract packages (0015). - Outbox table shape, relay cadence and dead-letter handling: TODO in the first-service spec.
Consequences
- No lost or phantom events; consumers must tolerate duplicates and reordering.
- An outbox table and relay per publishing service is a standing chore.