pgdb-queue v1.1.2 is a lightweight, Kafka-style asynchronous message queue built on PostgreSQL, eliminating the need for Kafka, Redis, or additional infrastructure. It uses PostgreSQL's LISTEN/NOTIFY for efficient, zero-polling wake-ups after draining, and row-level locking with FOR UPDATE SKIP LOCKED for concurrency. The library is ideal for startups or small apps needing reliable background processing with minimal operational overhead. It ships TypeScript types and provides a simple producer/consumer API with automatic retries and FIFO ordering.
npm install pgdb-queueNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates initializing the queue, producing a JSON message, and starting a continuous consumer with auto-wake via LISTEN/NOTIFY.
Wrap objects with JSON.stringify() before producing.
Ensure initQueue is awaited exactly once at startup.
Use 'schema.table' format when passing table name to initQueue.
Use startConsumer() for automatic wake and drainage.
Ensure initQueue completes before any other operations.
Call await initQueue(...) with correct schema-qualified table name.
Check database connection string and ensure initQueue resolves successfully.