Skip to main content

delete_queue

SQL 0.1.1 · Source cbff27b8a34e1384384018680e46c20d5c610cc9.

Signature​

postgremq.delete_queue(p_queue character varying)
RETURNS void

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

Remove a subscription and its backlog​

Deletes the queue and cascades its ordinary delivery rows, including in-flight work. Payloads remain for other references or later collection. A new queue using the same name is a new generation and receives only later publications.

Transactions and errors​

PMQ03: the pre-deletion check finds DLQ entries. A concurrent final nack can insert a dead letter after that check, causing the foreign-key restriction to fail with 23503 instead. Stop consumers and finish their settlement transactions before deleting the queue. Missing queue is a no-op. Locks and changes last until transaction end. This does not wait for application handlers to finish or undo their effects.

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.delete_queue('reference-jobs');
ROLLBACK;

The fixture queue is absent within the transaction. Rollback undoes this example’s creation, publication, and deletion, leaving no fixture queue.

Related: Topology, SQL conventions.