get_message
SQL 0.1.1 · Source cbff27b8a34e1384384018680e46c20d5c610cc9.
Signature
postgremq.get_message(p_message_id bigint)
RETURNS TABLE(message_id bigint, topic_name character varying, payload jsonb, published_at timestamp with time zone, group_key character varying, group_seq bigint)
The signature, defaults, and result above were extracted from the installed PostgreSQL catalog.
Read a publication and its payload
Returns the payload, topic, original publication time, and optional group metadata for a message ID. One shared payload can be referenced by several queues and dead-letter entries.
Transactions and errors
Read-only under caller privileges, including payload table SELECT. Missing or NULL ID returns no rows. Handle payload data with application-data access controls.
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.publish_message('reference-events', '{"number":1}'::jsonb) AS id \gset ref_
SELECT * FROM postgremq.get_message(:ref_id);
ROLLBACK;
The publication exists inside this transaction even without subscribers. No historical subscription is created by reading it.
Related: Publishing, SQL conventions.