
Security News
The AI Industry Is Betting on Open Weights
An open letter signed by 50 companies, from NVIDIA and Microsoft to Mistral and Hugging Face, urges Washington not to restrict open weight AI.
@craigbuckler/queue-mongodb
Advanced tools
A simple Node.js queuing system which uses MongoDB as a permanent data store.
A simple Node.js queuing system which uses MongoDB as a permanent data store.
Install the module with npm install queue-mongodb.
Database configuration parameters must be defined as environment variables or set in a .env file in the project root, e.g.
QUEUE_DB_HOST=localhost
QUEUE_DB_PORT=27017
QUEUE_DB_NAME=queuetest
QUEUE_DB_USER=root
QUEUE_DB_PASS=mysecret
A collection named queue will be added to the database.
The following example pushes three items to a queue named myqueue. Each item can be retreived up to three times at no more than 60 second intervals:
import { Queue } from 'queue-mongodb';
const myQueue = new Queue('myqueue', 3, 60);
// queue items
(async () => {
await myQueue.send( 'item 1' );
await myQueue.send( 42 ),
await myQueue.send( { a:1, b:2, c:3 } ),
})();
The next item on the queue can be retrieved, processed, and removed (perhaps in a script called using a cron job):
(async () => {
// fetch item
const qItem = await myQueue.receive();
// item is returned
if (qItem) {
// ...process...
// remove after successful processing
await myQueue.remove( qItem );
}
})();
If remove() is not run, processing is presumed to have failed. The item will be available again after 60 seconds for up to two more attempts.
Create a new queue handler.
| Param | Type | Default | Description |
|---|---|---|---|
| type | string | "DEFAULT" | queue identifier (any number of separate queues can be defined) |
| [maxRetries] | number | 5 | maximum number if times an item can be retrieved from the queue before processing is assumed to be complete |
| [processingTime] | number | 300 | maximum time in seconds a queued item held for processing |
qItemPush data to the queue. (Method is async and returns a Promise).
Kind: instance method of Queue
Returns: qItem - a queue item object: { _id, sent (date), runs (retries remaining), data }, or null when a failure occurs
| Param | Type | Default | Description |
|---|---|---|---|
| data | any | | data to queue |
| [maxRetries] | number | maximum number if times an item can be retrieved from the queue (overrides this.maxRetries) | |
| [delayUntil] | Date | date which can be set in the future to delay processing |
qItemRetrieve the next item from the queue. (Method is async and returns a Promise).
Kind: instance method of Queue
Returns: qItem - a queue item object: { _id, sent (date), runs (retries remaining), data }, or null when no items are available
numberRemove a queued item. (Method is async and returns a Promise).
This must be called once the item has been handled or it will be re-queued after this.processingTime.
Kind: instance method of Queue
Returns: number - the number of deleted items (normally 1).
| Param | Type | Description |
|---|---|---|
| qItem | qItem | the queue item to remove |
numberRemoves all queued items, including future ones. (Method is async and returns a Promise).
Kind: instance method of Queue
Returns: number - the number of deleted items.
numberCount of all queued items. (Method is async and returns a Promise).
Kind: instance method of Queue
Returns: number - items in the queue.
Clone the repository and run docker-compose up to launch MongoDB 4.4 and Node.js 14 containers. npm test runs various test functions.
FAQs
A simple Node.js queuing system which uses MongoDB as a permanent data store.
The npm package @craigbuckler/queue-mongodb receives a total of 4 weekly downloads. As such, @craigbuckler/queue-mongodb popularity was classified as not popular.
We found that @craigbuckler/queue-mongodb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
An open letter signed by 50 companies, from NVIDIA and Microsoft to Mistral and Hugging Face, urges Washington not to restrict open weight AI.

Security News
/Research
A fake corepack.org site is impersonating the Node.js tool and delivers an infostealer and proxyware to developers who download it.

Research
/Security News
A large-scale campaign abused GitHub Actions in compromised repositories to exploit CVE-2026-41940 in cPanel and WHM and steal server credentials.