# ADR-0001: Send order changes to the warehouse as events, not as a nightly file

Request: "Write the decision record for choosing event streaming over batch, with the patterns behind each option."

Run on 2026-11-13 against Blueprint Catalog 0.48.0. The company and its systems are fictional; the capability, pattern and anti-pattern ids are real and were checked against the catalog's API.

| Field | Value |
|---|---|
| Status | Proposed |
| Date | 2026-11-13 |
| Deciders | Head of supply chain systems |
| Consulted | Warehouse operations lead, order desk lead, integration engineer |
| Scope | [BC-670.10 Order Capture & Validation](https://catalog.mikereams.com/capabilities/BC-670.10), feeding [BC-650.40 Outbound Operations](https://catalog.mikereams.com/capabilities/BC-650.40) |

## Context

Order changes and cancellations are captured in the order system and reach the warehouse system in a nightly file. A change made after the file is cut is picked and shipped as the old order. Two systems act on an order change today (the warehouse and customer notifications) and reporting will be the third. The warehouse team cannot change the order system's database, and the order desk needs a change to reach the floor within minutes.

The catalog's reading path for BC-670.10 lists no patterns, so the patterns below were found by searching the pattern library.

## Options considered

1. **Keep the file and run it hourly.** No catalog pattern names this option, so none is cited. Each new consumer would need its own file and schedule, which is how [AP-040 Point-to-Point Spaghetti](https://catalog.mikereams.com/library#AP-040) starts.
2. **Publish order events.** [DP-130 Publish-Subscribe](https://catalog.mikereams.com/library#DP-130): several systems react to the same fact. What is published follows [DP-230 Domain Events](https://catalog.mikereams.com/library#DP-230); the order system emits through a [DP-290 Transactional Outbox](https://catalog.mikereams.com/library#DP-290); the warehouse is a [DP-180 Idempotent Consumer](https://catalog.mikereams.com/library#DP-180).
3. **Let the warehouse read the order tables.** Reading them directly is [AP-030 Shared Database Integration](https://catalog.mikereams.com/library#AP-030). Reading them through [DP-300 Change Data Capture](https://catalog.mikereams.com/library#DP-300) avoids touching the order system, at the price of events that describe rows, not business meaning: "line 4 updated", not "order cancelled".

## Decision

We will publish order events (option 2), because three systems need the same fact and a missed cancellation costs a shipment.

## Consequences

- **Gains:** a change reaches the warehouse in minutes; a new consumer subscribes without a new interface; a cancellation is a named event, not a difference between two files.
- **Costs:** event contracts that must be versioned, and no direct answer to "did anyone handle this" (DP-130); a relay process and an outbox table to prune (DP-290); a deduplication store with a retention window in the warehouse, and message ids the order system assigns consistently (DP-180); a decision about which events are internal and which are published contracts (DP-230).
- **Anti-patterns avoided:** AP-040 Point-to-Point Spaghetti and AP-030 Shared Database Integration.
- **Risks and follow-ups:** when a second team starts producing events, add a [DP-310 Schema Registry](https://catalog.mikereams.com/library#DP-310). Watch the age of the oldest unprocessed order event; a growing backlog means the warehouse consumer needs attention before the order desk notices.

## Links

- Pattern definitions, at their canonical sources: Publish-Subscribe <https://www.enterpriseintegrationpatterns.com/patterns/messaging/PublishSubscribeChannel.html>; Domain Events <https://martinfowler.com/eaaDev/DomainEvent.html>; Transactional Outbox <https://microservices.io/patterns/data/transactional-outbox.html>; Idempotent Consumer <https://microservices.io/patterns/communication-style/idempotent-consumer.html>; Change Data Capture <https://www.confluent.io/learn/change-data-capture/>; Schema Registry <https://docs.confluent.io/platform/current/schema-registry/index.html>.
- Ids checked on 2026-11-13: BC-670.10 and BC-650.40 return 200 and `active`; DP-130, DP-180, DP-230, DP-290, DP-300 and DP-310 are in `/api/v1/patterns.json`; AP-030 and AP-040 are in `/api/v1/anti-patterns.json`.

Capability, pattern and anti-pattern ids: Blueprint Catalog 0.48.0 (<https://catalog.mikereams.com>), CC BY 4.0, Mike Reams. Record layout: the catalog's template TM-10.
