requeue_dlq_messages
SQL 0.1.1 · Source cbff27b8a34e1384384018680e46c20d5c610cc9.
Signature
postgremq.requeue_dlq_messages(p_queue_name character varying)
RETURNS void
The signature, defaults, and result above were extracted from the installed PostgreSQL catalog.
Replay every dead letter for one queue
Moves all of that queue's DLQ entries into pending delivery state, clears old ownership/completion, resets attempts to zero, and sets visibility time to now; FIFO heads and other claim conditions still apply. Original group keys and sequences are preserved. Emits one queue notification if entries moved.
Transactions and errors
No selective message-ID argument exists. Replay is transactional and locks affected rows. It does not validate/revive Exclusive lifetime: replay into an expired queue can leave work to be removed by reaping. Prior effects and already completed successors are not undone.
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 * FROM postgremq.consume_message('reference-jobs', 30, 1) \gset claim_
SELECT postgremq.nack_message('reference-jobs', :claim_message_id, :'claim_consumer_token');
SELECT * FROM postgremq.consume_message('reference-jobs', 30, 1) \gset claim_
SELECT postgremq.nack_message('reference-jobs', :claim_message_id, :'claim_consumer_token');
SELECT postgremq.requeue_dlq_messages('reference-jobs');
ROLLBACK;
The fixture's final nack creates a dead letter, then replay creates a pending attempt-zero delivery.
Related: Dead letters, SQL conventions.