|
| 1 | +# purge-dlq |
| 2 | + |
| 3 | +Purge messages from a dead letter queue. |
| 4 | + |
| 5 | +## Synopsis |
| 6 | + |
| 7 | +```bash |
| 8 | +dotnet run -- purge-dlq -n <namespace> (-q <queue> | -t <topic> -s <subscription>) [options] |
| 9 | +``` |
| 10 | + |
| 11 | +## Options |
| 12 | + |
| 13 | +| Option | Short | Description | |
| 14 | +|--------|-------|-------------| |
| 15 | +| `--namespace` | `-n` | **(Required)** Fully qualified Service Bus namespace | |
| 16 | +| `--queue` | `-q` | Queue name | |
| 17 | +| `--topic` | `-t` | Topic name (requires `--subscription`) | |
| 18 | +| `--subscription` | `-s` | Subscription name (requires `--topic`) | |
| 19 | +| `--before` | | Only purge messages enqueued before this UTC datetime (ISO 8601) | |
| 20 | +| `--dry-run` | | Preview message count without purging | |
| 21 | +| `--interactive` | `-i` | Interactive mode: view and select categories to purge | |
| 22 | +| `--verbose` | `-v` | Enable verbose output | |
| 23 | + |
| 24 | +## Examples |
| 25 | + |
| 26 | +### Purge All Messages |
| 27 | + |
| 28 | +```bash |
| 29 | +# From a queue DLQ |
| 30 | +dotnet run -- purge-dlq -n mynamespace.servicebus.windows.net -q myqueue |
| 31 | + |
| 32 | +# From a topic subscription DLQ |
| 33 | +dotnet run -- purge-dlq -n mynamespace.servicebus.windows.net -t mytopic -s mysub |
| 34 | +``` |
| 35 | + |
| 36 | +### Dry Run |
| 37 | + |
| 38 | +Preview message count without purging: |
| 39 | + |
| 40 | +```bash |
| 41 | +dotnet run -- purge-dlq -n mynamespace.servicebus.windows.net -q myqueue --dry-run |
| 42 | +``` |
| 43 | + |
| 44 | +``` |
| 45 | +[DRY RUN] Found 1,523 messages in DLQ for queue 'myqueue' |
| 46 | +``` |
| 47 | + |
| 48 | +### Time-Based Filtering |
| 49 | + |
| 50 | +Purge only messages enqueued before a specific date: |
| 51 | + |
| 52 | +```bash |
| 53 | +dotnet run -- purge-dlq -n mynamespace.servicebus.windows.net -q myqueue --before 2024-01-01T00:00:00Z |
| 54 | +``` |
| 55 | + |
| 56 | +### Interactive Mode |
| 57 | + |
| 58 | +View messages grouped by Label and DeadLetterReason, then select which to purge: |
| 59 | + |
| 60 | +```bash |
| 61 | +dotnet run -- purge-dlq -n mynamespace.servicebus.windows.net -q myqueue -i |
| 62 | +``` |
| 63 | + |
| 64 | +``` |
| 65 | +Analyzing DLQ for queue 'myqueue'... |
| 66 | +Peeked 1,523 messages... |
| 67 | +
|
| 68 | +Dead Letter Summary: |
| 69 | +╭───┬─────────────────────┬────────────────────────────────┬───────╮ |
| 70 | +│ # │ Label │ DeadLetterReason │ Count │ |
| 71 | +├───┼─────────────────────┼────────────────────────────────┼───────┤ |
| 72 | +│ 1 │ OrderCreated │ MaxDeliveryCountExceeded │ 847 │ |
| 73 | +│ 2 │ PaymentProcessed │ MaxDeliveryCountExceeded │ 412 │ |
| 74 | +│ 3 │ (none) │ TTLExpiredException │ 198 │ |
| 75 | +│ 4 │ OrderCreated │ DeadLetterReasonHeader │ 66 │ |
| 76 | +╰───┴─────────────────────┴────────────────────────────────┴───────╯ |
| 77 | +Total: 1,523 messages |
| 78 | +
|
| 79 | +Select categories to purge (comma-separated numbers, 'all', or 'q' to quit): 1,3 |
| 80 | +Purging 1,045 messages from 2 categories... |
| 81 | +Purged 1,045 messages from DLQ for queue 'myqueue'. |
| 82 | +``` |
| 83 | + |
| 84 | +**Selection options:** |
| 85 | + |
| 86 | +| Input | Action | |
| 87 | +|-------|--------| |
| 88 | +| `1,3,5` | Select specific categories | |
| 89 | +| `1-5` | Select a range | |
| 90 | +| `all` / `a` | Select all categories | |
| 91 | +| `q` / empty | Quit without purging | |
| 92 | + |
| 93 | +## Required Permissions |
| 94 | + |
| 95 | +The authenticated identity needs one of these Azure RBAC roles: |
| 96 | + |
| 97 | +- **Azure Service Bus Data Owner** |
| 98 | +- **Azure Service Bus Data Receiver** |
0 commit comments