set_vt_batch_multi
SQL 0.1.1 · Source cbff27b8a34e1384384018680e46c20d5c610cc9.
Signature
postgremq.set_vt_batch_multi(p_queue_names character varying[], p_message_ids bigint[], p_consumer_tokens character varying[], p_vts integer[])
RETURNS TABLE(queue_name character varying, message_id bigint, vt timestamp with time zone, consumer_token character varying, outcome text)
The signature, defaults, and result above were extracted from the installed PostgreSQL catalog.
Renew claims with per-entry outcomes
Arrays are parallel: queue, message ID, token, and timeout seconds at the same position describe one claim. extended returns a confirmed new deadline; busy returns a null deadline and confirms neither ownership nor renewal. A missing result means the claim is no longer valid. Correlate by queue, ID, and token, not array order.
Transactions and errors
PMQ03: unequal lengths or NULL/negative timeout elements. NULL queue/ID/token entries match nothing and are omitted. Entries use per-row NOWAIT locking and subtransactions; returned successes still belong to the caller transaction. DDL or network stalls can exceed a row-lock policy, so clients need query deadlines.
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 * FROM postgremq.set_vt_batch_multi(
ARRAY['reference-jobs']::varchar[], ARRAY[:claim_message_id]::bigint[],
ARRAY[:'claim_consumer_token']::varchar[], ARRAY[60]);
ROLLBACK;
One extended result should identify the fixture claim and its token. Retry busy entries before the last deadline actually confirmed.
Related: Notifications and polling, SQL conventions.