PGMQ implements queues as SQL objects inside PostgreSQL with send, read, visibility timeouts, archiving, and FIFO or topic routing features.
Overview
PGMQ is a message queue implemented as PostgreSQL SQL objects, described as similar in spirit to AWS SQS or RSMQ but running entirely inside Postgres. It avoids separate brokers or background workers beyond the database itself.
Each named queue maps to tables under a dedicated schema. Producers call SQL functions to enqueue JSON messages; consumers read with a visibility timeout so a message stays hidden until processed or the timeout expires. Functions also support popping, deleting, archiving to per-queue archive tables, batch operations, and dropping queues.
FIFO queues with message group keys and topic-based routing with wildcard patterns are documented for ordered processing and publish-subscribe style delivery. Messages remain until explicitly removed or archived, supporting replay from archive tables.
You can install PGMQ as a Postgres extension or apply its SQL definitions directly when extensions are unavailable. A Docker image provides Postgres with the extension pre-installed, and client libraries exist in several languages for application code.
Key features
- Queues as Postgres tables and functions
- Visibility timeout consumer pattern
- JSON message payloads
- Archive tables for retention
- FIFO queues with group keys
- Topic routing with wildcards
- Postgres extension or SQL install
- Docker image with extension bundled
Use cases
- Job queues without RabbitMQ or Redis
- Exactly-once style processing with vt
- Event routing inside Postgres-centric stacks
- Archiving messages for later replay