A promise-based message queue for Node.js backed by MongoDB. Version 1.1.0 is the latest stable release. It provides a simple worker pattern where messages of a given type are processed by registered handlers, with built-in retry and rejection support. Compatible with MongoDB driver versions 4 through 6 and MongoDB server versions 5 through 7. Uses polling (default 1 second) to check for new messages. Differentiators: lightweight, no external dependencies besides MongoDB, and simple API.
npm install mongo-message-queueNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to instantiate MessageQueue, set up a MongoDB connection, register a worker with retry logic, and enqueue a message.
Update MongoDB driver to version 4.0.0 or higher.
Ensure the promise resolves to a Db object (from client.db()), not a MongoClient.
Use mQueue.stopPolling() when you no longer need to process messages.
Use (queueItem.retryCount || 0) to safely get the count.
Register all workers before enqueuing messages.
Set mQueue.databasePromise = async () => { return await client.db('queue'); };Check MONGO_URI environment variable or ensure MongoDB server is running.
Ensure enqueue is called with a valid message object.