CoAkka Runtime and Saga
Inventory and billing can record their results independently when an order goes through both. See when to keep work in one transaction and when to use a Saga to track completed steps and recover from failures.
Start with where each step commits
- One application transaction
- Place order → write order and reserve stock → commit together in one database
- Saga across independent commits
- Place order → inventory records a reservation → billing records the payment result → app confirms the order
When one application owns orders and stock and can update both in the same transaction, keep those steps together. CoAkka Runtime in Embedded mode can call handlers in the process. The application opens the transaction, and the database rolls back uncommitted changes if the transaction fails.
When inventory commits a reservation and billing works independently, a Saga tracks each outcome. If billing declines the payment, the app asks inventory to release the stock. The release is a new business operation that compensates for the committed reservation.
An external payment provider still commits independently, even when its client runs in the checkout process. See when to split out a capability.
CoAkka Runtime delivers requests. The app coordinates the Saga.
| Concern | CoAkka Runtime | Application or existing orchestrator |
|---|---|---|
| Call each step | Delivers requests to named targets and matches replies to requests. | Chooses the order. The example calls inventory.reserve before billing.charge. |
| Interpret the outcome | Returns a reply, reports a Deadletter with its reason, or signals that the wait timed out. | Reads the business result and decides whether to continue, reconcile the operation, or send a compensating request. |
| Recover after a restart | Delivers the requests the application sends after recovery. | Persists progress, operation IDs, and outcomes. Resumes unfinished work and handles retries without applying the same change twice. |
Where an orchestrator or outbox fits
See how a Temporal Activity calls CoAkka Runtime.
If you already have a Saga orchestrator, keep it in charge of progress and compensation. Try CoAkka Runtime for one request from the orchestrator to a handler.
When a step must be sent after updating status, the app can record both the status and the work to dispatch in one transaction. A worker reads the committed work and sends it through CoAkka Runtime. See how a transactional outbox recovers.
Stock is reserved and payment hits a problem
| What happened | What the application does |
|---|---|
| Billing confirms a decline | Record the decline and ask inventory to release the stored reservation. Finish canceling the order once inventory confirms the release. |
| The wait for a billing reply expires | Keep the order pending reconciliation. Look up the original operation ID with billing because the charge may have committed. Confirm the order or release stock once the outcome is known. If it remains unknown when the recovery window ends, keep it pending and hand it to an operator. |
| The release fails or the app restarts | Read the saved progress and reconcile the unfinished step before resuming. Reuse the same release operation ID on retry so inventory can recognize work it already performed. |
A Deadletter describes what happened during delivery or completion. Read its reason before deciding how to proceed. Billing confirms whether the payment was recorded. Look up Deadletter · Handle timeouts and retries.
Try one workflow in staging
- Run the call path. Use the basket demo to send a request from Node.js to Python. Observe the quote and what happens when the pricing service stops. This sample demonstrates communication.
- Choose one step in an existing Saga. Record what success means, where its outcome is stored, and how to reconcile it if the reply is lost. Keep the original call path available as a control.
- Test interruptions. Use fake inventory and billing services. Test a payment decline, a lost reply after a payment commits, and an app restart during stock release. Check the final order and stock state, the number of payments applied, and whether the workflow resumes from saved progress.