ADR-001: Coordinate checkout with a persisted Order saga
Finance uses Azure Durable Task Scheduler (DTS) keyed by Order ID to coordinate asynchronous checkout work without owning the Order aggregate.
1. Context & Problem
Customer checkout begins in Ordering, while follow-up steps—such as cleaning up the shopping basket and sending customer emails—occur across independently deployed capabilities. These steps cannot rely on a single continuous request or temporary in-memory tracking because outcome messages arrive later and services may restart in between.
At the same time, Finance’s role is coordination, not ownership of the purchase record. It needs to remember enough context to route basket cleanup and notifications while respecting that Basket, Ordering, and Notification each own their own records. Therefore, the checkout workflow requires both a durable shared reference and a clear completion rule.
2. Business Value
- Reliable post-checkout execution: Ensures follow-up work survives service restarts and delays between checkout and final order outcomes.
- Clear domain boundaries: Prevents Finance from becoming a competing owner of Order identity or lifecycle status.
- End-to-end traceability: Correlates every post-checkout action under a single, stable order reference for easier operations and support.
3. How It Works
When checkout completes, Finance starts a durable coordination workflow tied directly to the Order’s unique identifier:
- Stored coordination context: Finance keeps only the details needed to coordinate follow-up work—the basket reference, customer recipient details, order total, placement timestamp, current workflow stage, and timeout retry count.
- Stage progression: Explicit handlers track basket cleanup outcomes, Order status updates, and scheduled timeout checks across four stages: Placed, BasketDeletionFailed, Completed, and Cancelled.
- Clear completion rules: Removing the shopping basket is an intermediate step, not the end of the workflow; after successful basket cleanup, Finance continues waiting until Ordering explicitly reports that the Order is completed or cancelled. Conversely, if basket cleanup fails or retries run out, Finance can close its coordination workflow without changing the Order’s status in Ordering.
4. Trade-offs & Lessons Learned
- Persisted coordination vs. single-request chaining: Storing workflow state avoids holding connections open across independent deployments and prevents losing progress on restart, at the trade-off of depending on Finance’s database availability and compatible workflow mappings.
- Operational state vs. permanent audit history: The workflow record is operational coordination state, not a permanent audit log or the authoritative Order status—completing the workflow does not guarantee permanent retention of the record or prove that an email was delivered.
- No cross-system atomicity: Durable local state helps Finance resume work after interruptions, but does not make updates across Finance storage, messaging, Basket, Ordering, and Notification atomic.
- Confidential data protection: Because the workflow stores recipient details for later emails, Finance storage requires confidential-data access and retention controls.
- Alternatives rejected:
- Single synchronous request: Too fragile across independent deployments and unable to handle delayed outcome messages.
- In-memory workflow tracking: Loses progress and correlation upon restart or instance replacement.
- Making Finance the Order owner: Creates a second, conflicting authority for Order identity and lifecycle.
5. Technical Reference
Retrospective note: This ADR records the implemented architecture as of 2026-11-03; it does not assert an original approval date or identify unverified decision makers.
- Orchestration & persistence:
- Uses Wolverine’s
OrderSagain Order OrchestrationServicev1.0.0Order OrchestrationMessage-driven Finance workflow service that coordinates post-checkout basket cleanup and order notifications using Dura...PublishesPlaceOrderCommand, DeleteBasketCompleteCommand +3SubscribesUserCheckedOutIntegrationEvent, OrderStatusChangedToCompleteIntegrationEvent +3APIsAsyncAPIOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs, started by User checked outEventv1.0.0User checked outReports that an Order was placed and its checkout details are ready for Finance coordination. Ownercommerce-fulfillment-teamSchemaDiagramOpen docs. - Sets the saga ID to the Order ID and persists basket reference, recipient details, total, placement timestamp, workflow state (
Placed,BasketDeletionFailed,Completed,Cancelled), and timeout retry count in the Finance PostgreSQL database.
- Uses Wolverine’s
- Handlers & completion:
- Uses explicit handlers for basket outcomes, Order status events, and the local scheduled timeout.
- Terminal handlers call
MarkCompleted(); basket deletion success alone does not finish the saga. - Finance does not introduce another Order aggregate or a payment-processing model.
- Operational & architectural boundaries:
- PostgreSQL availability and compatible saga mappings are prerequisites for message processing.
- Persisted saga state does not make operations across PostgreSQL, Kafka, Basket, Ordering, and Notification atomic, and saga completion does not prove email delivery.