OrderProcessSaga
The order process, after the classic eShop's OrderProcessor: it drives an order through the stock validation in the inventory context, and compensates when the inventory refuses.
onOrderSubmitted: a submitted order moves on to await its stock validation.
onOrderAwaitingValidation: the order reserves each product's stock in the inventory, its lines of one product added up. The inventory is another context: the commands go to its command topic,
wow.eshop-inventory.commands.onReserveCommitted: a reservation the inventory commits comes back as a receipt on
wow.eshop-ordering.receiptsand confirms the order's product: the receipt names the stock, whose id is the product's.onReserveRejected: a reservation the inventory rejects (a short stock, a product it has no stock of) comes back as a receipt on the same topic and cancels the order.
onOrderCancelled: a cancelled order releases what the inventory reserved for it; a product reserved for nothing releases nothing.
onOrderShipped: a shipped order commits its reservations.
onReserveCommitted is a hop of a wait chain: a checkout's Wow-Wait follows the reservations to their commit in the inventory, then their receipts back to it, and on into the confirmations it derives.
Each handler names only its target's id: the contract the inventory api's jar carries assigns the reservations to the inventory's stock (whose id is the product's), the ordering's own Manifest assigns the order's commands to the order, and each command is in the tenant of the commit or receipt it answers.
Functions
A release the inventory rejects needs no compensation: it rejects one only for a product it has no stock of, which reserved nothing either. Without this handler, the rejection would park the order for the saga; returning Unit accepts it and derives nothing.
A product the inventory reserved confirms it on the order that asked for it.
A product the inventory cannot reserve cancels the order that asked for it.