mongo_job
A simple job queue implementation based on MongoDB's capped collections.
Install
npm install mongo_job
Usage
Assuming jobs
is a capped collection, created using the createCollection
method - for example you can do in the mongo console (this creates a 5M capped collection)
> db
Now, to create a worker:
var mongoJob = var MongoClient = MongoClientvar url = 'mongodb://127.0.0.1:27017/example' MongoClient
The worker will use MongoDB's tailable cursor to listen to any available new jobs, and work them when they are created.
Dispatching A Job
Dispatching a job is also simple:
var jobs = dbmongoJob