# pgmq — Postgres extension

> Message queues in SQL: send, read with a visibility timeout, archive.

Source: https://scribase.com/extensions/pgmq

Category: Jobs, queues and partitions. Version: 1.13.0. Optional, enabled per project.

## About

pgmq is a lightweight queue built on tables. A reader takes messages with a visibility timeout; if it crashes, the message becomes visible again after the timeout. Delete or archive a message once it is handled. Because it is Postgres, enqueueing can be part of the same transaction as the write that caused it.

## Enable it

```sql
create extension if not exists pgmq;
```

## Example

```sql
select pgmq.create('emails');

select pgmq.send('emails', '{"to": "ana@example.com", "template": "welcome"}');

-- take up to 5 messages, hidden from other readers for 30 seconds
select msg_id, message from pgmq.read('emails', 30, 5);

select pgmq.archive('emails', 1);
```

Upstream: https://github.com/pgmq/pgmq