Acme Marketing Architecture

7. Downstream change notification: change-feed outbox and message bus

7. Downstream change notification: change-feed outbox and message bus

Date: 2026-10-26

Status

Accepted


Problem

The brief asks for "timely visibility into important changes" and notes that downstream systems must learn when data changes. The architect suggested an outbox pattern and asked for a brainstorm against webhooks and real-time transport (WebSockets, SignalR, Server-Sent Events in .NET). Two different needs hide here:

  1. System-to-system: another system must react to a change (re-score a lead, refresh a cache, start a workflow). Needs durability, retries, dead-lettering, idempotency, and a contract.
  2. Human and UI: a dashboard tile updates, a Teams message is sent, an email goes out. Needs low latency and fan-out, tolerates loss.

A textbook outbox writes the event row in the same database transaction as the business row. Delta Lake commits are atomic per table, not across tables, so a gold.fact write and a gold.outbox write cannot share one transaction. Something else has to play the role of the transaction log.

The architect's reference for the downstream half is a statistical reporting platform at a public-sector agency, where "downstream" meant generated reports delivered to an external institution with sign-off, lineage and revision cycles. That half is handled by ADR 11 (publication pipeline). This record covers system-to-system and human notification of changes, which the publication pipeline also consumes (metrics.restated triggers re-publication).


Decision

We will use the Delta Change Data Feed as the outbox log, a relay that publishes changes to an Azure Service Bus topic, and adapters that subscribe to that topic for each delivery style.

  1. Business events are data. A Tier 1 event job, run every 15 minutes after the Silver jobs, evaluates the "important change" rule set (business architecture) over the Silver change feed, carries the subject's vault token (assigned at the Bronze gate, so no identifier is ever involved), and inserts rows into gold.business_event (event type, subject key, generalised before and after values, occurred-at, source version) if absent on a deterministic event_id = hash(event_type, subject_key, source_version, rule_version). The hourly and nightly star builds add aggregate-level events (for example spend.pacing_alert, metrics.restated) the same way. Change Data Feed is enabled on business_event and on Silver tables, not on Gold facts, whose day-level rebuilds would appear as whole-day churn.
  2. CDF is the outbox. The event row is persisted exactly once, in business_event; the change feed of that table is the log the relay reads, so there is no separate outbox write to keep consistent with an event table. A crash between a Silver write and the event job leaves events to be produced by the next run, which is idempotent because the ids are deterministic. The relay reads table_changes('gold.business_event', last_version + 1) after each event job and star build, publishes each row, and stores the last published version in control.outbox_cursor. If the relay crashes after publishing and before storing the cursor, the next run republishes; consumers deduplicate on event_id.
  3. Service Bus topic data-changed with one subscription per consumer, SQL filters on event type, duplicate detection on event_id (10-minute window), dead-letter queue per subscription, sessions keyed by subject where ordering per entity matters. Volume is thousands of events per hour at most; this is a messaging workload, not telemetry.
  4. Adapters (each a subscriber, none called by the pipeline):
    • Webhook dispatcher (.NET on Azure Functions): subscriber registry (URL, secret, event filter, active flag), HMAC-signed payload, exponential retry, dead-letter after N attempts, delivery log. External systems register once; nothing in the pipeline knows they exist.
    • Push gateway for UIs (.NET 10 ASP.NET Core): Server-Sent Events via TypedResults.ServerSentEvents for one-way dashboard updates (simplest, HTTP-native, auto-reconnect with Last-Event-ID); Azure SignalR Service or Web PubSub if bidirectional messaging or very large fan-out appears. The gateway is itself a Service Bus subscriber.
    • Fabric Activator for human notifications: an eventstream sourced from the Service Bus topic feeds Activator rules that send Teams messages or email, or trigger a Fabric pipeline (for example, reframe the semantic model, or run a downstream Dataflow). Fabric job events (failed runs) also go to Activator. Caveat: the Service Bus eventstream source authenticates with a shared access key (no managed identity) and is not covered by Git integration or deployment pipelines today, so that key lives in Key Vault and the eventstream is configured per environment by runbook, as a documented exception to "everything as code".
  5. Pull remains available. Batch consumers may read Gold through the SQL analytics endpoint or read the business_event change feed directly with a version cursor. This is the cheapest integration for consumers that run nightly.

Considered Options

Option Summary Pros Cons
✅ CDF-derived outbox → Service Bus topic → adapters Transaction-log tailing variant of the outbox No dual write; replayable by version; durable fan-out with per-consumer DLQ; webhooks, SSE and Teams are all adapters of one bus Relay and cursor to operate; Service Bus is one more Azure resource
Classic outbox table written by the Gold jobs Job writes gold.outbox after writing facts, with ids minted per run Familiar Event rows are a second commit with no way to regenerate what was lost between the two, and run-minted ids duplicate on every re-run. The chosen design keeps the single event table but derives ids from Silver versions, so the table is regenerable and re-runs are no-ops. Rejected in its non-deterministic form.
Direct webhooks from the pipeline Pipeline Web activity calls each consumer Nothing to deploy Pipeline knows every consumer; a slow consumer slows ingestion; retries and DLQ reinvented per call. Rejected (violates AP-03).
Azure Event Grid custom topic Push to HTTP endpoints with retry and dead-letter Cheaper per event than Service Bus for pure webhooks; native push No sessions or ordering; weaker dedupe; consumers must be HTTP endpoints. Viable if every consumer is a webhook; Service Bus chosen for the mixed case.
Azure Event Hubs Partitioned log Millions of events per second; replay by offset Overkill at thousands per hour; consumers must manage checkpoints; no DLQ. Reserve for a future clickstream source.
Fabric Activator only Rules on OneLake or eventstream events No Azure resources; great for Teams and email and for triggering Fabric items Not a system-to-system contract: no durable delivery guarantees to external endpoints beyond Power Automate; OneLake events are file-level, not row-level. Kept for human alerts and Fabric orchestration.
Consumers poll Gold or CDF No push at all Simplest; good for nightly consumers Does not meet "timely visibility" for systems that need minutes. Kept as the batch option.
WebSockets or SignalR directly from the pipeline Pipeline pushes to UI Lowest latency Pipeline coupled to UI sessions; no durability. SSE/SignalR kept, but only as a subscriber of the bus.

Consequences

Positive:

Negative / Trade-offs:

Risks: | Risk ID | Description | Impact (E/H/M/L) | Mitigation | |---------|-------------|------------------|------------| | R1 | VACUUM removes CDF files before the relay has read them | M | Relay runs after each event job and star build; VACUUM retention on Gold is 30 days; alert if cursor lag exceeds 1 day | | R2 | A consumer requires exactly-once | L | Documented at-least-once contract; event_id dedupe on both sides | | R3 | SSE connections buffered by a proxy | L | Disable response buffering on the gateway route; fall back to SignalR if infrastructure cannot stream |