Deleting and Archiving¶
Archive a Message¶
Archiving moves a message from the queue to the archive table. Archived messages are retained for auditing but are no longer visible to readers.
Archive a Batch¶
Delete a Message¶
Deleting permanently removes a message. It cannot be recovered.
Delete a Batch¶
Pop a Message¶
pop reads and immediately deletes a message in a single atomic operation. This is useful when you want to process a message exactly once without worrying about visibility timeouts.
You can also pop multiple messages at once:
Return Type¶
- If
qty == 1, returnsMessage | None. - If
qty > 1, returnslist[Message].
Purge a Queue¶
Remove all messages from a queue without dropping the queue itself:
Detach Archive¶
Detach the archive table from PGMQ management. This is deprecated in PGMQ v2.0 but retained for backward compatibility.
Convert Archive to Partitioned¶
If your archive table has grown very large, you can convert it to a partitioned table:
queue.convert_archive_partitioned(
"my_queue",
partition_interval=10000,
retention_interval=100000,
leading_partition=10,
)
| Parameter | Description |
|---|---|
partition_interval |
Rows per partition. |
retention_interval |
Retained partitions. |
leading_partition |
Number of future partitions to create. |