Skip to main content

clean_up_queue

SQL 0.1.1 · Source cbff27b8a34e1384384018680e46c20d5c610cc9.

Signature​

postgremq.clean_up_queue(p_queue character varying)
RETURNS void

The signature, defaults, and result above were extracted from the installed PostgreSQL catalog.

Discard every delivery in one queue​

Deletes all queue delivery rows, including pending, processing, and completed rows. It does not delete the queue, payloads, or DLQ entries. Despite the name, this is not age-based retention.

Transactions and errors​

Destructive and transactional; active workers can lose their delivery and already performed external effects remain. Missing queue is a no-op. It has no batch limit and emits no queue wake-up.

All calls require the applicable caller privileges. See SQL errors for driver failures and uncertain outcomes.

Example​

Run in psql with ON_ERROR_STOP and fresh reference-* names. ROLLBACK removes the fixtures.

BEGIN;
SELECT postgremq.create_topic('reference-events');
SELECT postgremq.create_queue('reference-jobs', 'reference-events', 2, false);
SELECT postgremq.publish_message('reference-events', '{"number":1}'::jsonb) AS id \gset ref_
SELECT postgremq.clean_up_queue('reference-jobs');
ROLLBACK;

The queue remains declared with zero ordinary delivery rows from this fixture. Dead-letter entries, if any, are untouched.

Related: Topology, SQL conventions.