ACME HQDemo work items and pages, made up for Emargen's demo. Not a real company.
Engineering / Engineering / Architecture decision records

ADR-004: Events leave identity-service through an outbox

By Marek Nowak · created 17 May 2021, 12:00 UTC · last updated 1 Jun 2021, 08:30 UTC · version 2

adreventsoutboxidentity-servicenotifier

Status: accepted · Date: 17 May 2021 · Decided by: Marek Nowak, Rafael Duarte

Context

identity-service sends emails itself, from queue jobs dispatched inside controllers. Two problems in the last month:

We are moving sending into its own service (ADR-005), so identity-service needs a reliable way to say "this happened" to something outside its database.

Decision

identity-service writes every event to an outbox_events table in the same transaction as the change that caused it. A relay job publishes unpublished rows, in order, to a queue, and marks them published. Consumers get each event at least once and must ignore ids they have already handled.

We considered publishing straight to the queue after commit. It loses events when the process dies between the commit and the publish, and it can't be tested without the queue.

Consequences

Updates