Skip to content

pgmb

A simple PostgreSQL Message Broker system

Overview

PackageVersionCategoryLicenseLanguage
pgmb1.0.0FEATPostgreSQLSQL
IDExtensionBinLibLoadCreateTrustRelocSchema
2670pgmbNoNoNoYesNoNopgmb

Archived upstream. Requires pg_cron and http; preload pg_cron in its configured database. RPM 1.0.0-2PGSTY fixes schema creation and requires pgsql_http; existing DEBs retain the upstream schema-creation failure. Delay arguments do not delay dispatch; retries have no exponential backoff.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY1.0.01817161514pgmbpg_cron, http
RPMPIGSTY1.0.01817161514pgmb_$vpg_cron_$v, pgsql_http_$v
DEBPIGSTY1.0.01817161514postgresql-$v-pgmbpostgresql-$v-cron, postgresql-$v-http
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u22.x86_64
u22.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u24.x86_64
u24.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u26.x86_64
u26.aarch64

Build

You can build the RPM / DEB packages for pgmb using pig build:

pig build pkg pgmb         # build RPM / DEB packages

Install

You can install pgmb directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

Install
pig install pgmb;          # Install for current active PG version
pig
pig ext install -y pgmb -v 18  # PG 18
pig ext install -y pgmb -v 17  # PG 17
pig ext install -y pgmb -v 16  # PG 16
pig ext install -y pgmb -v 15  # PG 15
pig ext install -y pgmb -v 14  # PG 14
dnf
dnf install -y pgmb_18       # PG 18
dnf install -y pgmb_17       # PG 17
dnf install -y pgmb_16       # PG 16
dnf install -y pgmb_15       # PG 15
dnf install -y pgmb_14       # PG 14
apt
apt install -y postgresql-18-pgmb   # PG 18
apt install -y postgresql-17-pgmb   # PG 17
apt install -y postgresql-16-pgmb   # PG 16
apt install -y postgresql-15-pgmb   # PG 15
apt install -y postgresql-14-pgmb   # PG 14

Create Extension:

CREATE EXTENSION pgmb CASCADE;  -- requires: pg_cron, http

Usage

Sources:

pgmb implements a SQL message broker with worker endpoints, routing-key patterns, queues and HTTP dispatch scheduled through pg_cron. The upstream repository is archived.

Installation and compatibility

The RPM revision 1.0.0-2PGSTY requires pgsql_http_N and removes a redundant schema-creation statement. Earlier RPMs and existing DEB packages retain the upstream SQL and can fail at CREATE EXTENSION pgmb because the control file and install script both create the schema. Package installation alone does not establish that the extension can be created.

Install as a superuser. The required extensions are pg_cron and http; pgmb itself does not require preload. Configure the scheduler for the database in which the extension will be used:

shared_preload_libraries = 'pg_cron'
cron.database_name = 'postgres'

Restart PostgreSQL, connect to that database, and create the dependencies before the extension:

CREATE EXTENSION pg_cron;
CREATE EXTENSION http;
CREATE EXTENSION pgmb;

Register a queue and send a message

The worker endpoint receives HTTP requests from the database server. Use a trusted endpoint and restrict who can register workers.

SELECT pgmb.create(
    'orders', 'order.*', 3,
    pgmb.worker('order_worker', 'http://127.0.0.1:8080/worker', 100)
);

SELECT pgmb.send(
    gen_random_uuid(), 'order.created', '{"order_id": 123}'::jsonb
);

SELECT * FROM pgmb.workers;
SELECT * FROM pgmb.queues;
SELECT * FROM pgmb.orders_queue;
SELECT * FROM pgmb.orders_dead_letter_queue;

The argument order for pgmb.create is name, binding pattern, maximum retries, then worker UUID. A trigger routes messages to matching queues, and queue creation registers a scheduler job.

API

FunctionPurpose
pgmb.worker(name, endpoint, rps)Register a worker and return its UUID; rps limits the batch size per dispatch.
pgmb.create(name, binding_key, max_retries, worker_id)Create a queue, its dead-letter table and scheduler job; return the queue UUID.
pgmb.send(id, routing_key, body)Store a JSONB message and route it to matching queues.
pgmb.send overloadsAccept optional headers and an integer-seconds or timestamp delay.
pgmb.dispatch_messages(queue_id)Dispatch a batch; mark successful HTTP responses acknowledged, retry failures and move exhausted messages to the dead-letter table.

Limits of version 1.0.0

  • Delays populate enqueued_at, but the dispatcher does not filter out future timestamps; the overloads do not guarantee delayed delivery.
  • Headers are stored with messages, but the dispatcher sends only the body using http_post; they are not forwarded as custom HTTP headers.
  • Retries use a counter on subsequent dispatches. The SQL does not implement exponential backoff.
  • HTTP effects are external to the database transaction. Review delivery and retention requirements before relying on this archived project.

Was this page helpful?