Domain Events & Integration Contracts
Mappings of emitted events and asynchronous downstream domain interactions.
Domain Events & Integration Contracts
The Inventory & WMS domain communicates changes in state asynchronously by publishing Domain Events. Downstream systems consume these events without direct database dependencies.
1. Emitted Domain Events Table
| Event Name | Triggering Condition | Payload Parameters | Downstream Impact |
|---|---|---|---|
ItemStockReceived | GRN Approved | SKU, Quantity, Batch, Warehouse, Value | Treasury / FMS: Updates Inventory Asset value. Procurement: Reconciles Purchase Order. |
ItemStockExhausted | ATP reaches 0 | SKU, Warehouse | Procurement: Triggers auto-reorder workflow. Sales: Hides product from storefront. |
StockTransferred | GIN Closed | SKU, Qty, Source, Target | Logistics: Validates route optimization stats. |
SerialAllocated | Reservation Made | SKU, Serial Number, Sales Order ID | Sales: Confirms item matches picking order. |
StockQuarantined | Quarantine Note Posted | SKU, Qty, Lot, Reason | QA Context: Triggers inspection review workflows. |
2. Downstream Domain Interactions
Financial Management (FMS) / Treasury Integration
- Mechanism: The WMS context does not execute general ledger double-entry bookkeeping. Instead, it emits
ItemStockReceivedandStockQuarantined(with valuation metrics in the payload). - FMS Reaction: The FMS system consumes these events asynchronously to adjust asset accounting sheets (e.g. debiting inventory assets and crediting liabilities upon receiving).
Procurement Integration (Auto-Reordering)
-
Mechanism: The WMS context calculates stock levels against thresholds and emits
ItemStockExhaustedorStockLevelFellBelowMinimum. -
The Reorder Invariant: The event
StockLevelFellBelowMinimumis dispatched when:$$\text{ATP} + \text{Inbound Pending POs} < \text{Minimum Reorder Threshold}$$
-
Procurement Reaction: The Procurement system automatically triggers reorder pipelines, generating purchase order drafts without WMS intervention.
3. Integration Contract Guarantees
- At-Least-Once Delivery: The message queue guarantees that every inventory change event is delivered to the broker at least once. Downstream consumers must implement idempotent processing to prevent duplicate ledger updates.
- Payload Immutability: Domain event payloads are structured, read-only structures representing a historical fact that cannot be rewritten.
4. Event Payload Structures (Interface Contracts)
Downstream consumers rely on strict, versioned schemas representing the domain events.
Payload: ItemStockReceived
EventID: Unique UUID tracking the event transmission.Timestamp: ISO 8601 timestamp of GRN approval.SKU: Product identifier code.BatchNumber: The lot identifier matching quality records.Quantity: Integer representing total count received.UnitValue: Monetary acquisition value per item (used by FMS for MAC calculations).WarehouseID: Destination storage facility identification code.
Payload: ItemStockExhausted
EventID: Unique UUID tracking the event transmission.Timestamp: ISO 8601 timestamp of stock depletion.SKU: Product identifier code.WarehouseID: Facility where stock has been exhausted.SafetyStockRemaining: Boolean indicating if safety stock buffers are still intact.