nack_message
SQL 0.1.1 · Source cbff27b8a34e1384384018680e46c20d5c610cc9.
Signature
postgremq.nack_message(p_queue_name character varying, p_message_id bigint, p_consumer_token character varying, p_delay_until timestamp with time zone DEFAULT clock_timestamp())
RETURNS void
The signature, defaults, and result above were extracted from the installed PostgreSQL catalog.
Return attempted work or retire its final attempt
A non-final nack returns the delivery to pending, clears ownership, and sets its next visibility timestamp. It retains the claim attempt count. On the final finite attempt it moves to the DLQ immediately. A final grouped retirement permits the next group member to proceed.
Transactions and errors
PMQ01: processing state/token no longer matches. NULL delay can raise 23502. Acquires delivery and queue locks until caller transaction end; can delay Exclusive renewal. No delay overrides the attempt limit. Elapsed VT alone does not reject a matching token.
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',
clock_timestamp() + interval '10 seconds');
ROLLBACK;
With the fixture limit of two, its first nack returns a pending delivery with attempt count 1 and a future deadline.
Related: Retries, SQL conventions.