Skip to content

Queues

Tested with: Databasezy API v1 · PostgreSQL 17 · pgmq 1.13

Queues are durable message queues stored in your Postgres instance with pgmq. Messages are read with a visibility timeout, so a worker that crashes does not lose them, and processed messages can be archived for later inspection. Open the instance in the portal and choose Queues.

SQL
select pgmq.create('emails');
select pgmq.send('emails', '{"to": "[email protected]", "template": "welcome"}');
-- Read up to 10 messages and hide them from other readers for 30 seconds
select * from pgmq.read('emails', 30, 10);
-- Done with message 1: archive it (or pgmq.delete to drop it)
select pgmq.archive('emails', 1);
shell
zb api POST /v1/orgs/{org}/instances/inst_01jb.../queues -d '{"name": "emails"}'
zb api POST /v1/orgs/{org}/instances/inst_01jb.../queues/emails/messages -d '{
"messages": [{"to": "[email protected]"}], "delay_seconds": 0
}'
zb api GET /v1/orgs/{org}/instances/inst_01jb.../queues # depth, total messages, age of the oldest

unlogged: true creates a faster queue that does not survive a crash.

Roles listed in a queue’s data_api_roles (default service_role) can use it through the Data API with the pgmq_public functions send, send_batch, read, pop, archive and delete. Change the roles with PUT .../queues/<name>/permissions.