Events
Outbox types are written with OutboxWriterService inside prisma.$transaction. On the worker, the dispatcher calls every @OutboxHandler declared for the eventType, each under its own consumer name. See Async processing for retry and reporting.
Outbox types
| eventType | Producers | Consumers (consumerName) |
|---|---|---|
order.created | order command, marketplace ingestion | OrderFulfillmentListener (fulfillment.order-created.v1, locks order), ReceivableRecognitionListener (settlement.receivable-recognition.created.v1, non-transactional) |
order.confirmed | order command | WalletListener (wallet.order-token-deduction.v1) |
order.location.changed | order command | OrderFulfillmentListener (fulfillment.order-location-changed.v1, locks order) |
order.status.changed | order status service, return command | OrderFulfillmentListener (fulfillment.order-status-changed.v1, locks order), OutboundOrderSyncListener (outbound-order-sync.status-changed.v1), ReceivableRecognitionListener (settlement.receivable-recognition.v1) |
order.address.resolution_triggered | order command | WhatsAppAddressResolutionListener (whatsapp.address-resolution.v1) |
order.channel-awb.reported | Flipkart and Amazon order sync | ChannelAwbFulfillmentListener (fulfillment.channel-awb.v1, locks order) |
shipment.status.changed | shipment command, shipment courier service, iThink, Shipway and Shiprocket webhooks and tracking | ShipmentFulfillmentListener (fulfillment.shipment-status.v1), NdrShipmentListener (shipment.ndr-terminal-status.v1), ReturnShipmentListener (returns.shipment-status.v1) |
stock.sync.requested | order command, stock count, fulfillment, returns, stock transfer, goods receipt, allocation | ProductStockSyncListener (stock.channel-sync.v1) |
stock.received | stock command | StockAllocationListener (fulfillment.stock-allocation.v1) |
Constants: STOCK_EVENTS.SYNC_REQUESTED = stock.sync.requested, STOCK_EVENTS.RECEIVED = stock.received, SHIPMENT_STATUS_CHANGED = shipment.status.changed, CHANNEL_AWB_REPORTED = order.channel-awb.reported. shipmentStatusChanged(event) and channelAwbReported(event) in src/common/events/domain-events.ts build the outbox input.
order.status.changed from the order status service carries source (API, CHANNEL_SYNC, FULFILLMENT_ROLLUP). OutboundOrderSyncListener does not push a CHANNEL_SYNC change back to the channel that reported it: at best that is a no-op, and on a channel that takes a status as given (WooCommerce) it rewrote the channel's own, finer state, for instance a pending-payment order put on-hold by PointNXT's payment hold. The return command's event has no source and is pushed as before.
order.channel-awb.reported carries an AWB a marketplace issued for an order it has the seller ship (CHANNEL_SHIPPED only: not channel-fulfilled orders such as FBA, nor orders our courier or a dropship vendor ships). It is written in the same transaction as the order update that stored the AWB, and raised every time the channel reports the shipment with one, not only the first time. The consumer records it against a fulfillment that is packing or later and has no AWB yet, under the courier the channel named or, failing that, the channel's preferred courier. Finding nothing to do is not an error.
shipment.status.changed is written in the same transaction as the status update, so fulfillment, NDR and returns react after the courier update commits, on the worker. A consumer that needs to write uses the transaction the dispatcher passes it.
Non-transactional (transactional: false) consumers: receivable recognition (both), wallet debit, outbound order sync, WhatsApp address resolution, return shipment, stock allocation and channel stock sync. They run their own queries or call external systems, so they are called with no transaction open and must be safe to repeat. The others write through the dispatcher's transaction.
Payload types live under src/common/events. Dispatch is by the eventType string.
Code map
| Piece | Path |
|---|---|
| Fulfillment on order events | order-fulfillment.listener.ts |
| Receivables | receivable-recognition.listener.ts |
| Wallet debit | wallet.listener.ts |
| Outbound channel status | outbound-order-sync.listener.ts |
| Stock arrival | stock-allocation.listener.ts |
| Inventory publish buffer | product-stock-sync.listener.ts |
| WhatsApp address | whatsapp-address-resolution.listener.ts |
| Shipment to fulfillment | shipment-fulfillment.listener.ts |
| Channel-issued AWB | channel-awb-fulfillment.listener.ts |
| NDR | ndr-shipment.listener.ts |
| Return shipment | return-shipment.listener.ts |
Failure
A throw inside the business transaction rolls back the aggregate and the outbox row together. A throw in a consumer happens after commit: the dispatcher retries that event, skips consumers that already succeeded, and reports the failure to Sentry on the first attempt and when the event goes DEAD.
How to add an event: Adding an event.