Registry / messaging / elephantmq

elephantmq

JSON →
library1.0.3jsnpmunverified

PostgreSQL-native job queue for Node.js 18+, featuring transactional enqueue, familiar producer/worker API, and no external broker. Current stable version 1.0.3. Releases are ad-hoc via npm. Key differentiators: atomic enqueue within database transactions via Queue.inTransaction, full SQL visibility into queue state, and one less datastore to manage vs Redis-based queues like BullMQ.

npm install elephantmq
INSTALL
IMPORT
SIG · ELEPHANTMQ
E
elephantmq
messagingjavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Queue
import { Queue } from 'elephantmq'
const Queue = require('elephantmq').Queue
ESM import only; package is ESM-only (type: module). CommonJS require('./node_modules/elephantmq') will fail.
Worker
import { Worker } from 'elephantmq'
import Worker from 'elephantmq/worker'
Worker is a named export, not default. No separate worker subpath.
migrate
import { migrate } from 'elephantmq/migrate'
import { migrate } from 'elephantmq'
migrate is exported from 'elephantmq/migrate' subpath, not the main module.

Demonstrates migration, job enqueue, and basic worker processing with Pool connection.

import { Queue, Worker } from 'elephantmq'; import { migrate } from 'elephantmq/migrate'; import { Pool } from 'pg'; const pool = new Pool({ connectionString: process.env.DATABASE_URL ?? '' }); // Run migrations once await migrate(pool, 'public'); const queue = new Queue('emails', { connection: pool }); await queue.add('welcome', { userId: 42 }); const worker = new Worker('emails', async job => { console.log('Processing job', job.id); // sendEmail(job.data.userId); return { processed: true }; }, { connection: pool }); worker.on('completed', job => console.log('Done', job.id)); await new Promise(resolve => setTimeout(resolve, 5000)); worker.close(); await pool.end();
Debug
Known issues
breakingMinimum Node.js version >=18; older versions fail at import
fix
Upgrade Node to v18 or later
affects: <18
breakingMinimum PostgreSQL 14 required; older versions lack features
fix
Upgrade PostgreSQL to v14+
affects: <14
breakingelephantmq is ESM-only; require() will throw ERR_REQUIRE_ESM
fix
Use import syntax or dynamic import()
affects: *
deprecatedmigrate() automatic lazy migration on first connect (skipMigrations:true recommended in production)
fix
In production, run migrate separately and set skipMigrations: true in Queue/Worker options
affects: *
gotchaMissing 'pg' peer dependency will cause runtime error: 'Cannot find module pg'
fix
Install 'pg' alongside elephantmq
affects: *
gotchaWorker concurrency defaults to 1; high-throughput jobs may starve
fix
Set concurrency option to desired parallelism
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'pg'
pg is a peer dependency not automatically installed
fix
npm install pg
TypeError: Class extends value #<Object> is not a constructor or null
CommonJS require() used on ESM-only package
fix
Use import syntax or dynamic import()
Error: connect ECONNREFUSED ::1:5432
No PostgreSQL server running or wrong connection string
fix
Ensure PostgreSQL is running and DATABASE_URL is correct
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
pgrequiredPostgreSQL client required for queue operations
Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources
elephantmq — npm install elephantmq · libregistry