---
id: bookworm.{env}.finance.delete-basket-failed
name: Failed Basket Cleanup Command Channel
version: 1.0.0
type: topic
summary: |
  Kafka topic owned by the commerce-fulfillment-team carrying Finance's failed
  basket-cleanup compensation command consumed by Order API.
owners:
  - commerce-fulfillment-team
badges:
  - content: Kafka
    backgroundColor: blue
    textColor: blue
  - content: Compensation
    backgroundColor: orange
    textColor: orange
address: bookworm.{env}.finance.delete-basket-failed
parameters:
  env:
    enum:
      - development
      - staging
      - production
    default: development
    examples:
      - development
      - staging
      - production
    description: BookWorm deployment environment.
deliveryGuarantee: at-least-once
protocols:
  - kafka
deadLetterChannel:
  id: bookworm.{env}.ordering.dead-letter-queue
  version: 1.0.0
---

## Purpose & Scope

This compensation topic transports failed basket-cleanup commands published by [[service|order-orchestration]] when [[service|basket-api]] reports a cleanup failure or the checkout saga must compensate for a timeout. [[service|order-api]] consumes this command to soft-delete the order record without changing its business status. This channel is distinct from Basket's upstream failure event topic, [[channel|bookworm.&#123;env&#125;.basket.delete-failed]].

## Channel Specification

| Property                               | Value                                                                       |
| :------------------------------------- | :-------------------------------------------------------------------------- |
| **Bounded Context / Owner**            | [[domain\|ordering]] / [[team\|commerce-fulfillment-team]]                  |
| **Channel Type**                       | Topic                                                                       |
| **Address Pattern**                    | `bookworm.{env}.finance.delete-basket-failed`                               |
| **Parameters**                         | `env` (`development`, `staging`, `production`; default: `development`)      |
| **Protocol & Envelope Format**         | Kafka + CloudEvents JSON (`application/json`)                               |
| **Partition Key & Ordering Guarantee** | Keyed by `orderId`; preserves per-order command ordering within a partition |
| **Delivery Semantics**                 | At-least-once                                                               |
| **Dead-Letter Channel**                | [[channel\|bookworm.&#123;env&#125;.ordering.dead-letter-queue]]            |

## Messages & Participants

| Message                                | Type    | Producer                         | Consumer(s)            | Consumer Group            |
| :------------------------------------- | :------ | :------------------------------- | :--------------------- | :------------------------ |
| [[command\|DeleteBasketFailedCommand]] | Command | [[service\|order-orchestration]] | [[service\|order-api]] | Ordering service consumer |

## Ordering, Retries & Failure Handling

- **Partition-key ordering:** Keying by `orderId` serializes compensation commands for a given order within its partition.
- **Transient retries:** [[service|order-api]] applies bounded retries with backoff for transient database or service faults.
- **Immediate DLQ routing:** Malformed payloads, deserialization errors, or exhausted retries route to [[channel|bookworm.&#123;env&#125;.ordering.dead-letter-queue]].
- **Consumer idempotency:** If the order record is already absent, processing is a safe no-op; operators must verify order state before replaying so an active order is not unintentionally soft-deleted.

## Channel Details & Visualization

<ChannelInformation />

<NodeGraph />

## Related Documentation

- [[channel|bookworm.&#123;env&#125;.ordering.dead-letter-queue]] — Consumer dead-letter queue
- [[channel|bookworm.&#123;env&#125;.basket.delete-failed]] — Upstream Basket failure event topic
- [[channel|bookworm.&#123;env&#125;.finance.delete-basket-complete]] — Paired cleanup success command topic
- [[service|order-orchestration]] — Command producer
- [[service|order-api]] — Compensation consumer
- [[flow|user-checkout]] — End-to-end checkout workflow
- [[doc|arc42/08-crosscutting-concepts/002-contracts-and-messaging]] — Messaging standards and idempotency rules
