|
| 1 | +--- |
| 2 | +title: Pause and Purge |
| 3 | +pcx_content_type: concept |
| 4 | +sidebar: |
| 5 | + order: 2 |
| 6 | +--- |
| 7 | +import { WranglerConfig, Type, MetaInfo } from "~/components"; |
| 8 | + |
| 9 | +## Pause Delivery |
| 10 | + |
| 11 | +You can pause delivery of messages from your queue to any connected consumers. Pausing a queue is useful when managing downtime (for example, if your consumer Worker is unhealthy) without losing any messages. |
| 12 | + |
| 13 | +Queues continue to receive and store messages even while delivery is paused. Messages in a paused queue are still subject to expiry, if the messages become older than the queue message retention period. |
| 14 | + |
| 15 | +Pausing affects both [push-based consumer Workers](/queues/reference/how-queues-works#consumers) and [pull based consumers](/queues/configuration/pull-consumers). |
| 16 | + |
| 17 | +### Pause and resume delivery using Wrangler |
| 18 | + |
| 19 | +The following command will pause message delivery from your queue: |
| 20 | + |
| 21 | +```sh |
| 22 | +$ npx run wrangler queues pause-delivery <QUEUE-NAME> |
| 23 | +``` |
| 24 | + |
| 25 | +- `queue-name` <Type text="string" /> <MetaInfo text="required" /> |
| 26 | + - The name of the queue for which delivery should be paused. |
| 27 | + |
| 28 | +The following command will resume message delivery: |
| 29 | + |
| 30 | +```sh |
| 31 | +$ npx run wrangler queues resume-delivery <QUEUE-NAME> |
| 32 | +``` |
| 33 | + |
| 34 | +- `queue-name` <Type text="string" /> <MetaInfo text="required" /> |
| 35 | + - The name of the queue for which delivery should be resumed. |
| 36 | + |
| 37 | +### What happens to HTTP Pull consumers with a paused queue? |
| 38 | +When a queue is paused, messages cannot be pulled by an [HTTP pull based consumer](/queues/configuration/pull-consumers). Requests to pull messages will receive a `409` response, along with an error message stating `queue_delivery_paused`. |
| 39 | + |
| 40 | +## Purge queue |
| 41 | +Purging a queue permanently deletes any messages currently stored in the Queue. Purging is useful while developing a new application, especially to clear out any test data. It can also be useful in production to handle scenarios when a batch of bad messages have been sent to a Queue. |
| 42 | + |
| 43 | +Note that any in flight messages, which are currently being processed by consumers, might still be processed. Messages sent to a queue during a purge operation might not be purged. Any delayed messages will also be deleted from the queue. |
| 44 | + |
| 45 | +:::caution |
| 46 | +Purging a queue is an irreversible operation. Make sure to use this operation carefully. |
| 47 | +::: |
| 48 | + |
| 49 | +### Purge queue using Wrangler |
| 50 | +The following command will purge messages from your queue. You will be prompted to enter the queue name to confirm the operation. |
| 51 | +```sh |
| 52 | +$ npx run wrangler queues purge <QUEUE-NAME> |
| 53 | + |
| 54 | +This operation will permanently delete all the messages in Queue <QUEUE-NAME>. Type <QUEUE-NAME> to proceed. |
| 55 | +``` |
| 56 | + |
| 57 | +### Does purging a Queue affect my bill? |
| 58 | +Purging a queue counts as a single billable operation, regardless of how many messages are deleted. For example, if you purge a queue which has 100 messages, all 100 messages will be permanently deleted, and you will be billed for 1 billable operation. Refer to the [pricing](/queues/platform/pricing) page for more information about how Queues is billed. |
0 commit comments