Registry / messaging / docmq
library0.5.7jsnpmunverified

A document-based messaging queue for MongoDB (v4.7+), PostgreSQL (v8.7+), and other databases via a custom driver interface. Current stable version is 0.5.7. Released as an alternative to BullMQ and Agenda, DocMQ prioritizes database abstraction, timezone-aware scheduling, and in-memory development mode over raw performance. It supports concurrency, job repetition, scheduling, persistence, and queue-level hooks. Suitable when persistence and scheduling across timezones are critical, but not for high-throughput FIFO scenarios. Releases are infrequent; the package ships TypeScript types and is ESM-only.

npm install docmq
INSTALL
IMPORT
SIG · DOCMQ
D
docmq
messagingjavascriptv0.5.7
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.

DocMQ
import { DocMQ } from 'docmq'
const DocMQ = require('docmq')
DocMQ is ESM-only; CJS require will fail.
MongoDriver
import { MongoDriver } from 'docmq'
Named export for MongoDB backend driver.
PostgresDriver
import { PostgresDriver } from 'docmq'
Named export for PostgreSQL backend driver.
InMemoryDriver
import { InMemoryDriver } from 'docmq'
import InMemoryDriver from 'docmq'
Default export does not exist; must use named import.

Initializes a DocMQ instance with in-memory driver, registers a handler, schedules a delayed job, and waits for the result.

import { DocMQ, InMemoryDriver } from 'docmq'; async function main() { const docMq = new DocMQ({ driver: new InMemoryDriver() }); await docMq.start(); // Define a job handler await docMq.handle('email', async (job) => { console.log(`Sending email to ${job.data.to}`); return { sent: true }; }); // Schedule a job const job = await docMq.schedule('email', { to: 'user@example.com' }, { delay: '5m' }); console.log('Job scheduled:', job.id); // Wait for completion const result = await job.result(); console.log('Job result:', result); await docMq.stop(); } main().catch(console.error);
Debug
Known issues
gotchaESM-only package: DocMQ uses ES modules and cannot be required with CommonJS. Must use import syntax.
fix
Ensure your project is configured for ESM (type: 'module' in package.json) or use dynamic import() if necessary.
affects: >=0.5.0
gotchaMongoDB driver v4+ required: DocMQ relies on mongodb@^4.7.0. Do not use older versions.
fix
Install mongodb@^4.7.0 as a dependency.
affects: >=0.5.0
gotchaPostgreSQL driver v8+ required: DocMQ relies on pg@^8.7.3. Do not use older versions.
fix
Install pg@^8.7.3 as a dependency.
affects: >=0.5.0
gotchaIn-memory driver data is lost on restart: The InMemoryDriver does not persist jobs; use only for development/testing.
fix
Switch to MongoDriver or PostgresDriver for production.
affects: >=0.5.0
gotchaNo default export: Attempting import DocMQ from 'docmq' will fail; must use named import.
fix
Use import { DocMQ } from 'docmq'.
affects: >=0.5.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
DocMQ is ESM-only and cannot be loaded with require()
fix
Use import syntax or switch to ESM mode in your project.
TypeError: docMq is not a constructor
Attempted to use default import instead of named import
fix
Use import { DocMQ } from 'docmq' instead of import DocMQ from 'docmq'.
MongoParseError: options appName, ... are not supported
Using an incompatible version of mongodb driver
fix
Install mongodb@^4.7.0.
Upgrade
Version history
0.5.7latest on npm
Audit
Dependencies
mongodboptionalRequired driver for MongoDB backend (optional if not used)
pgoptionalRequired driver for PostgreSQL backend (optional if not used)
Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
packagedocmq
docmq — npm install docmq · libregistry