79 releases

new 0.32.0 Feb 14, 2026
0.31.2 Dec 20, 2025
0.31.0 Aug 9, 2025
0.30.1 May 23, 2025
0.9.0 Mar 29, 2023

#162 in Database interfaces

Download history 608/week @ 2025-10-27 724/week @ 2025-11-03 768/week @ 2025-11-10 463/week @ 2025-11-17 613/week @ 2025-11-24 1319/week @ 2025-12-01 3562/week @ 2025-12-08 1696/week @ 2025-12-15 791/week @ 2025-12-22 364/week @ 2025-12-29 2813/week @ 2026-01-05 1372/week @ 2026-01-12 2196/week @ 2026-01-19 2219/week @ 2026-01-26 1173/week @ 2026-02-02 1561/week @ 2026-02-09

7,161 downloads per month
Used in 9 crates (7 directly)

PostgreSQL

89KB
1.5K SLoC

Postgres Message Queue (PGMQ)

Latest Version

The Rust client for PGMQ. This gives you an ORM-like experience with the Postgres extension and makes managing connection pools, transactions, and serialization/deserialization much easier.

Installing PGMQ

PGMQ can be installed into any existing Postgres database using this Rust client.

Run standard Postgres using Docker:

docker run -d -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:latest

Via CLI

Install the PGMQ Rust CLI:

cargo install pgmq --features cli --bin pgmq-cli

pgmq-cli install postgres://postgres:postgres@localhost:5432/postgres

In Rust

Refer to the install example, or add PGMQ to your Cargo.toml with the cli feature enabled:

cargo add pgmq --features cli
use pgmq::PGMQueueExt;

let db_url = "postgres://postgres:postgres@localhost:5432/postgres".to_string();
let queue = pgmq::PGMQueueExt::new(db_url, 2)
    .await
    .expect("failed to connect to postgres");

queue.install_sql(Some(&"1.10.0".to_string())).await;

Examples

The project contains several examples. You can run these using Cargo.

A basic example displaying the primary features:

cargo run --example basic

How to install PGMQ using the Rust client from within your application:

cargo run --example install --features cli

Serialization and Deserialization

Messages can be parsed as serde_json::Value or into a struct of your design. queue.read() returns an Result<Option<Message<T>>, PgmqError> where T is the type of the message on the queue. It returns an error when there is an issue parsing the message (PgmqError::JsonParsingError) or if PGMQ is unable to reach postgres (PgmqError::DatabaseError).

License: PostgreSQL

Dependencies

~41–59MB
~883K SLoC