Skip to main content

release_message

SQL 0.1.1 · Source cbff27b8a34e1384384018680e46c20d5c610cc9.

Signature​

postgremq.release_message(p_queue_name character varying, p_message_id bigint, p_consumer_token character varying)
RETURNS void

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

Return work that was never attempted​

Returns the owned processing delivery to pending immediately, clears ownership, and decrements its attempt count by one without going below zero. This refunds the claim for unattempted buffered work. It emits a queue wake-up on commit.

Transactions and errors​

PMQ01: matching processing delivery/token not found. Elapsed VT alone does not reject a matching token. Update locks last until transaction end. Do not use release for a failed business attempt; it can circumvent the retry limit.

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.release_message('reference-jobs', :claim_message_id, :'claim_consumer_token');
ROLLBACK;

The fixture returns to pending with its first claim increment refunded.

Related: Acknowledgements, SQL conventions.