Skip to content

Instantly share code, notes, and snippets.

@strndy
strndy / read_topic.sql
Created July 15, 2025 07:06
topic support pgmq
CREATE OR REPLACE FUNCTION public.read_topic(
queue_name text,
qty int,
sleep_seconds int,
topic text
)
RETURNS TABLE (
msg_id bigint,
read_ct int,
enqueued_at timestamptz,
return cache(url, ttlSeconds * 1000, async () => {
const response = await request(url);
return JSON.parse(response);
});