set_vt
SQL 0.1.1 · Source cbff27b8a34e1384384018680e46c20d5c610cc9.
Signature
postgremq.set_vt(p_queue_name character varying, p_message_id bigint, p_consumer_token character varying, p_vt integer)
RETURNS timestamp with time zone
The signature, defaults, and result above were extracted from the installed PostgreSQL catalog.
Set a new deadline on a still-valid claim
Sets the lease deadline to database now plus the supplied number of seconds and returns that timestamp. It replaces the deadline rather than adding to it. Unlike ordinary ack/nack/release, this operation requires an unexpired lease.
Transactions and errors
PMQ03: negative timeout. PMQ01: missing/wrong token, non-processing, or expired lease. 55P03: row locked by another transaction; NOWAIT does not wait for that row. NULL timeout can produce 23502. Zero is allowed at SQL level. Locks last until commit.
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.set_vt('reference-jobs', :claim_message_id, :'claim_consumer_token', 60);
ROLLBACK;
The returned deadline is about 60 seconds from the server call. This does not renew the queue lifetime.
Related: Visibility timeouts, SQL conventions.