ADR-005: Publish explicit basket cleanup outcomes
Checkout basket deletion publishes distinct completion and failure integration events so downstream workflows can recover deliberately.
1. Context & Problem
Once checkout passes a customer’s purchase intent to downstream order processing, the submitted BasketEntityv1.0.0BasketCustomer-scoped, mutable pre-order collection of requested books and quantities managed prior to checkout.Ownercommerce-fulfillment-teamOpen docs must be cleared so it cannot be reused by mistake. However, deleting the basket can fail on its own after the order has already started. Treating a failed cleanup as a success would leave an already-submitted cart active, while confusing a cleanup failure with a failed order would cause serious business and customer-support errors.
2. Business Value
- Prevents accidental cart reuse: Confirms when a checked-out basket has been safely cleared.
- Protects order integrity: Ensures a temporary cart cleanup issue is never misinterpreted as a failed order or failed payment.
- Actionable failure recovery: Gives downstream teams and operations clear visibility when cleanup fails so they can trigger targeted recovery or follow-up steps.
3. How It Works
After checkout begins processing an order, it sends a cleanup request to delete the customer’s basket. If the deletion succeeds, the cart service announces a cleanup-completed outcome. If deletion fails, it announces a separate cleanup-failed outcome instead.
These two outcomes travel along separate communication channels so downstream systems and monitoring tools can tell successful cleanups apart from cases that need recovery. Neither announcement means that payment or order processing is finished, and a cleanup failure never cancels or alters ownership of the confirmed order. Because Finance may resend the cleanup request after a timeout—and Notification also listens to that request to send new-order emails—every receiving system must safely handle duplicate messages.
4. Trade-offs & Lessons Learned
- Duplicate-safe consumers required: Because cleanup requests and outcome messages can be retried after timeouts, every downstream consumer (including both basket cleanup and order notification emails) must safely handle receiving the same message more than once.
- Independent monitoring needed: Operations teams must monitor both the completion and failure channels separately to spot repeated outcomes and unresolved cleanup failures.
- Outcome reporting, not delivery guarantees: Publishing explicit outcomes tells downstream systems what happened during cleanup, but it does not guarantee single-attempt execution or prescribe a specific retry schedule.
5. Technical Reference
- Publisher: Basket APIServicev1.0.0Basket APIInternal HTTP and gRPC service for managing customer-scoped shopping baskets, Catalog price enrichment, and post-checkou...PublishesGetBookGrpc, GetBooksGrpc +2SubscribesCreateBasket, UpdateBasket +4APIsOpenAPI, AsyncAPIOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs
- Completion event & channel:
- Event: Basket deletion completedEventv1.0.0Basket deletion completedIndicates that Basket successfully deleted the submitted basket during checkout cleanup. Ownercommerce-fulfillment-teamSchemaDiagramOpen docs (published only when deletion succeeds)
- Channel:
bookworm.{env}.basket.delete-complete - Payload: order ID, basket ID, and total
- Failure event & channel:
- Event: Basket deletion failedEventv1.0.0Basket deletion failedIndicates that Basket could not delete the submitted basket during checkout cleanup. Ownercommerce-fulfillment-teamSchemaDiagramOpen docs (published when deletion fails)
- Channel:
bookworm.{env}.basket.delete-failed - Payload: order ID, basket ID, total, and customer email (may be
null)
- Cross-service interaction & idempotency: Finance may reissue the checkout cleanup command after a timeout, and Notification also consumes that command for new-order email processing. All command and integration-event consumers must be idempotent and cannot assume single delivery.