PHPackages                             tuxweb-it/amp-sql-queue - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. tuxweb-it/amp-sql-queue

ActiveLibrary[Database &amp; ORM](/categories/database)

tuxweb-it/amp-sql-queue
=======================

Async non-blocking SQL job queue for AMPHP, PostgreSQL, MySQL, and MariaDB.

0.2.3(2mo ago)04MITPHPPHP ^8.3

Since May 7Pushed 2mo agoCompare

[ Source](https://github.com/TuxWeb/amp-sql-queue)[ Packagist](https://packagist.org/packages/tuxweb-it/amp-sql-queue)[ RSS](/packages/tuxweb-it-amp-sql-queue/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (6)Versions (2)Used By (0)

amp-sql-queue
=============

[](#amp-sql-queue)

Persistent, async, non-blocking SQL job queue for PHP 8.3+, AMPHP, Revolt, PostgreSQL, MySQL, and MariaDB.

`amp-sql-queue` provides one queue API over two SQL storage backends:

- `PostgresQueueStorage` using `amphp/postgres`
- `MysqlQueueStorage` using `amphp/mysql`

It is designed as a small library, not a framework integration. There is no PDO, Doctrine DBAL, Symfony, Laravel, or blocking database client in the runtime path.

Status
------

[](#status)

This project is an early open source base. The core API, worker, SQL storage classes, migrations, examples, PHPUnit tests, and PHPStan configuration are present. Database-backed integration tests are available and run when PostgreSQL/MySQL DSNs are configured.

Features
--------

[](#features)

- One public API for PostgreSQL, MySQL, and MariaDB
- Real async/non-blocking database access through AMPHP
- Persistent SQL-backed jobs
- Atomic reservation with `SELECT ... FOR UPDATE SKIP LOCKED`
- Delayed jobs via `available_at`
- Priority ordering
- Lease / visibility timeout via `locked_until`
- Manual lease extension for long-running jobs
- Recovery of abandoned jobs
- Retry with exponential backoff
- Dead letter table
- Optional idempotency key
- Dispatch receipts with job id and insert/deduplication status
- Worker lifecycle hooks for observability
- Concurrent workers in the same PHP process
- Multiple worker processes through SQL row locking
- PostgreSQL `LISTEN/NOTIFY` with polling fallback
- MySQL adaptive polling
- JSON serializer by default
- Extensible contracts
- Typed exceptions
- Separate PostgreSQL and MySQL migrations

Requirements
------------

[](#requirements)

- PHP 8.3+
- Composer
- PostgreSQL 12+ recommended, with `FOR UPDATE SKIP LOCKED`
- MySQL 8.0+ or MariaDB 10.6+ required for `FOR UPDATE SKIP LOCKED`

Core runtime dependencies:

- `amphp/amp`
- `revolt/event-loop`

Install the database driver you need:

- `amphp/postgres` for `PostgresQueueStorage`
- `amphp/mysql` for `MysqlQueueStorage` with MySQL or MariaDB

Development dependencies:

- PHPUnit
- PHPStan

Installation
------------

[](#installation)

```
composer require tuxweb-it/amp-sql-queue amphp/postgres
```

For MySQL or MariaDB:

```
composer require tuxweb-it/amp-sql-queue amphp/mysql
```

For local development in this repository:

```
composer install
```

Database Schema
---------------

[](#database-schema)

Apply the migration for your database.

PostgreSQL:

```
psql "$AMP_SQL_QUEUE_POSTGRES_DSN" -f migrations/postgres/001_create_queue_tables.sql
```

MySQL / MariaDB:

```
mysql "$AMP_SQL_QUEUE_MYSQL_DSN"
