PGMQ logo

PGMQ

Lightweight PostgreSQL‑based message queue with exactly‑once delivery

PGMQ adds a simple, dependency‑free message queue to PostgreSQL, offering SQS‑compatible APIs, exact‑once delivery, delayed messages, and archiving, all via SQL functions.

PGMQ banner

Overview

Overview

PGMQ brings a lightweight, SQL‑native message queue to PostgreSQL, targeting developers and operations teams that already rely on Postgres for data storage. By exposing SQS‑compatible functions, it lets applications publish, read, and manage messages without provisioning a separate broker.

Capabilities

Create queues as tables, send JSON payloads, read with configurable visibility timeouts, pop for immediate deletion, and archive for long‑term retention and replay. The extension supports delayed delivery, batch operations, and works with PostgreSQL 14‑18. A broad set of client libraries (Rust, Go, Python, Java, .NET, JavaScript, etc.) enables seamless integration across languages.

Deployment

Start instantly with the official Docker image that bundles PostgreSQL and the pgmq extension, or install the extension into an existing database. No background workers or external services are required—everything runs as plain SQL functions, simplifying operations and reducing infrastructure overhead.

Highlights

Exactly‑once delivery with configurable visibility timeout
Zero external services – pure SQL functions in a Postgres extension
SQS‑compatible API for easy migration
Built‑in archiving for long‑term retention and replay

Pros

  • Leverages existing PostgreSQL infrastructure, no separate broker needed
  • Simple SQL interface works with any language that can execute queries
  • Supports delayed messages and visibility timeouts for reliable processing
  • Archiving enables audit trails and message replay

Considerations

  • Performance limited to PostgreSQL's capabilities
  • Scaling beyond a single Postgres instance requires external sharding
  • Advanced features like priority queues are not provided
  • Requires PostgreSQL version 14‑18; older versions unsupported

Managed products teams compare with

When teams consider PGMQ, these hosted platforms usually appear on the same shortlist.

Amazon SQS logo

Amazon SQS

Fully managed message queuing service for decoupling and scaling distributed applications

Azure Service Bus logo

Azure Service Bus

Fully managed enterprise message broker for decoupling applications via message queues and publish/subscribe topics

Google Pub/Sub logo

Google Pub/Sub

Global messaging service for event ingestion and fan‑out

Looking for a hosted option? These are the services engineering teams benchmark against before choosing open source.

Fit guide

Great for

  • Teams already using PostgreSQL who need lightweight queuing
  • Applications preferring SQL‑based integration over external brokers
  • Workloads requiring message replay or audit via archiving
  • Projects needing SQS‑compatible semantics without AWS costs

Not ideal when

  • High‑throughput systems that outgrow single‑node Postgres limits
  • Use cases demanding priority queues or complex routing
  • Environments without PostgreSQL or with versions older than 14
  • Scenarios requiring built‑in distributed consensus across multiple brokers

How teams use it

Event‑driven microservices communication

Services publish events to a PGMQ queue and consume them reliably with exactly‑once semantics, eliminating external broker costs.

Delayed job processing

Schedule tasks by sending messages with a delay; workers read them after the visibility timeout, enabling simple retry and back‑off strategies.

Audit trail and replay

Archive processed messages to the built‑in archive tables, allowing later inspection or reprocessing of historical events.

Migration from AWS SQS

Replace SQS with PGMQ using the compatible API, reducing cloud dependency while keeping existing client code.

Tech snapshot

PLpgSQL52%
Rust40%
Python7%
Makefile1%
Shell1%
Ruby1%

Tags

message-queue

Frequently asked questions

Do I need a separate worker process for PGMQ?

No, PGMQ operates entirely within PostgreSQL via functions; consumers poll the queue using standard SQL.

Which PostgreSQL versions are supported?

PGMQ is compatible with PostgreSQL 14 through 18.

How is exactly‑once delivery achieved?

Messages are hidden for a configurable visibility timeout; if not deleted or archived they become visible again, ensuring a single successful consumer processes each message.

Can I use PGMQ with my existing database?

Yes, install the pgmq extension into any existing PostgreSQL instance without additional services.

Is there a Docker image for quick start?

A pre‑built Docker image (ghcr.io/pgmq/pg18-pgmq) includes PostgreSQL with the extension ready to use.

Project at a glance

Active
Stars
4,363
Watchers
4,363
Forks
125
LicensePostgreSQL
Repo age2 years old
Last commit3 days ago
Primary languagePLpgSQL

Last synced 12 hours ago