The fastest way to get started is by running the docker image, where PGMQ comes pre-installed.
docker run -d --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 ghcr.io/pgmq/pgmq-pg:latestPGXN is a distributed network of extensions that make it easier to install and manage PostgreSQL extensions.
Install PGXN Client:
You can install the PGXN client by following the instructions provided in the PGXN Client Installation Guide
Install PGMQ using PGXN
pgxn install pgmqAlternatively, you can manually install PGMQ by downloading and building from the source using the following commands:
Note: Run these commands as the user who owns the PostgreSQL installation (often
rooton Unix-based systems) or usesudoif necessary.
curl -LO https://api.pgxn.org/dist/pgmq/1.4.2/pgmq-1.4.2.zip
unzip pgmq-1.4.2.zip
cd pgmq-1.4.2
make
make install
PGMQ requires the postgres-server-dev package to build. For example, to install
version 14 on ubuntu:
sudo apt-get install postgres-server-dev-14If you're working on native Windows, follow these steps to install and build pgmq:
- Install PostgreSQL for Windows
-
Download the official PostgreSQL installer from PostgreSQL Windows Downloads.
-
Follow the installation process, ensuring you include pgAdmin and Command Line Tools
-
After installation, add the PostgreSQL binary directory (typically
C:\Program Files\PostgreSQL\<version>\bin) to your system'sPATHenvironment variable. This will allow access to PostgreSQL tools likepg_config.
- Install Build Tools (MinGW)
- Download and install MinGW from MinGW. Select the GCC compiler for C/C++
- During installation, ensure the binaries are added to the
PATH. MinGW is essential for compiling thepgmqextension on Windows.
- Install
pgmqfrom Source
- Download the
pgmqsource:
Invoke-WebRequest -Uri https://api.pgxn.org/dist/pgmq/1.4.2/pgmq-1.4.2.zip -OutFile pgmq-1.4.2.zip
Expand-Archive -Path pgmq-1.4.2.zip -DestinationPath .\pgmq-1.4.2
cd .\pgmq-1.4.2
- Build and install `pgmq`: Use the following commands to compile and install pgmq using MinGW:
```bash
make PG_CONFIG="C:/Program Files/PostgreSQL/<version>/bin/pg_config"
make install- Create the pgmq Extension
- After installation, connect to PostgreSQL and create the pgmq extension:
CREATE EXTENSION pgmq cascade;If you are using macOS, you can install PostgreSQL and build PGMQ using Homebrew.
- Install PostgreSQL using Homebrew:
brew install postgresql- Clone the PGMQ repository and build it:
git clone https://github.com/pgmq/pgmq.git
cd pgmq/pgmq-extension
make
sudo make install- Create the extension in PostgreSQL:
CREATE EXTENSION pgmq cascade;If you already have Postgres installed locally, you can skip to Install PGMQ to Postgres.
If you need to install Postgres or want to set up a new environment for PGMQ development, pgenv is a command line utility that makes it very easy to install and manage multiple versions of Postgres.
Follow the installation instructions to install it.
If you are on MacOS, you may need link brew link icu4c --force in order to successfully build Postgres.
Install Postgres 16.3
pgenv build 16.3
pgenv use 16.3Connect to Postgres:
psql -U postgresA fresh install will have not have PGMQ installed.
postgres=# \dx
List of installed extensions
Name | Version | Schema | Description
---------+---------+------------+------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(1 row)
Clone the repo and change into the directory.
git clone https://github.com/pgmq/pgmq.git
cd pgmq/pgmq-extensionThis will install the extension to the Postgres using the pg_config that is currently on your PATH. If you have multiple versions of Postgres installed, make sure you are using the correct installation by running make install PG_CONFIG=/path/to/pg_config.
make
make installFinally, you can create the extension and get started with the example in the README.md.
CREATE EXTENSION pgmq cascade;
If you are working with partitioned queues, you will need to install pg_partman version <= 4.7.0
make install-pg-partmanThen,
CREATE EXTENSION pg_partman;Tests are written for pg_regress and pg_isolation_regress. The latter is available on Postgres 14 and higher, so the Makefile skips them for earlier versions.
Once you have a postgres instance with the extension installed, run:
make installcheckThe PGMQ Postgres Extension is released as a bundle with Postgres (in a container) and as PGXN distribution. Both of these flows are managed in a Github workflow. To create a release,
- Update and commit the new valid semver version in pgmq.control.
- Create a Github release using the extension's version for the
tagandtitle. Auto-generate the release notes and/or add more relevant details as needed.
Postgres images with PGMQ and all required dependencies are built and published to ghcr.io/pgmq/pg{PG_VERSION}-pgmq:{TAG} for all supported Postgres versions and PGMQ releases.
The required extension files are publish to and hosted at PGXN.
See subdirectories for the Rust and Python SDK release processes.