0031. Publish ProductClassified through the outbox on both topics
Status
Accepted; publication part superseded by
ADR 0034 (the write path no
longer raises ProductClassified; only the one-shot backfill command emits
it). Supersedes only the "in-process only / never published" clause
of ADR 0024 for
ProductClassified. Every other decision in ADR 0024 (CloudEvents 1.0
structured mode, type/dataschema conventions, consumer rules) stands, and
LocationRecorded remains in-process only.
Context
ProductClassification is SKU-level master data this service owns as source
of truth (ADR 0009).
ClassifyProduct has always raised a ProductClassified domain event, but
neither Kafka encoder mapped it, so ADR 0024 recorded it as delivered
in-process only ("if it is ever published, its entity segment is product").
The consequence is that every sibling that needs a SKU's handling attributes
polls GET /products/{sku}/classification per call: order-management,
wes-work-planning and fulfillment-execution each carry a REST client plus a
PRODUCT_CLASSIFICATION_MODE switch and a circuit breaker for it.
The 2026-10-05 audit flagged this as a hotspot, and the architect decided on
2026-10-06 (decision 9b): master data owned here is published as an event so
siblings can keep a local copy instead of polling. LocationRecorded, by
contrast, has no consumer and no stated need, and stays in-process.
Decision
-
ProductClassifiedis published on both existing topics, through the transactional outbox (ADR 0017): theOutboxPublisherfans it out to the integration encoder (warehouse.inventory.events) and the analytics encoder (warehouse.inventory.analytics) inside the sameUnitOfWorkas the classification save, so the event commits with the aggregate or not at all. The directEVENT_PUBLISHER=kafkapath forwards it too. -
Wire contract (additive; no existing type or payload changes):
attribute value typecom.warehouse.wms.inventory-storage.product.ProductClassified(entityproduct)subject/ Kafka keythe SKU, so reclassifications of one SKU stay ordered on one partition (ADR 0021) dataschemaurn:warehouse:inventory-storage:events:ProductClassified:v1and...:analytics:ProductClassified:v1data{sku, handling_tags[], temperature_class?, dot_hazard_class?}— the same shape on both topicshandling_tagsis the aggregate's stable enum order.temperature_classanddot_hazard_classare omitted when unset. The payload is a full-state replacement of the SKU's classification: a consumer overwrites its local row, and an absent optional field means "none". It is SKU handling data only — no PII. -
The analytics projector ignores it.
cmd/inventory-projectordispatches on the fulltypeand acknowledges unknown types without touching the read model (regression test:TestAnalyticsConsumer_IgnoresProductClassified). The analytics-topic copy exists so the type is available on the stream that already carries this context's other occurrences; the Flow & Accuracy report does not use it. -
LocationRecordedstays in-process (no consumer; a test pins that neither encoder maps it). Publishing it later would be a new ADR. -
No consumer changes here. REST
GET /products/{sku}/classificationstays (additive migration path). Moving order-management, wes-work-planning and fulfillment-execution off polling is each of those repositories' own decision; they can adopt the event whenever they choose.
Consequences
- Siblings can build a local classification copy from
warehouse.inventory.events(replay from the earliest offset gives them the current state per SKU, since each message is a full replacement keyed by SKU). Until a SKU is next re-classified, a consumer that starts mid-stream only learns its classification from the REST read or from a topic replay — this change does not backfill historical classifications onto the topic. - The integration topic's published contract grows by one additive message;
consumers already must ignore unknown
typevalues (ADR 0024). The known consumer of that topic (wes-work-planning's stock projection) dispatches on the fulltypeand is unaffected. - One more outbox row per classify call per topic (two rows).
- Verification: exact-JSON goldens for both topics
(
internal/adapters/outbound/kafka/product_classified_test.go), and a testcontainers Postgres test proving the rows commit with — and roll back with — the classification (internal/adapters/outbound/postgres/product_classified_outbox_integration_test.go).