Node.js job queue backed by MongoDB

npm install mojo
1 downloads in the last day
6 downloads in the last week
25 downloads in the last month

mojo -- a MongoDB job queue

WARNING API is subject to change.

Mojo is a job queue inspired by Resque, but is trying to improve certain shortcomings of Resque's design. In particular, mojo makes it impossible to loose jobs. Jobs are kept in the database until workers have successfully completed them and only then are they removed from the database.

Even if your host or application crashes hard (without chance to catch the exception in the application's runtime), no jobs are lost.


mojo = require 'mojo'

# First declare your job by extending mojo.Template
class Addition extends mojo.Template
  perform: (a, b) ->
    console.log a + ' + ' + b + ' = ' + (a + b)

# Create a connection to the database
options = host: 'localhost', port: 27017, db: 'test'
connection = new mojo.Connection options

# Listen to connection errors
connection.on 'error', console.error

# Put some jobs into the queue
connection.enqueue, 1, 1
connection.enqueue, 2, 4
connection.enqueue, 3, 6
connection.enqueue, 4, 8

# Now you need a worker who will process the jobs
worker = new mojo.Worker connection, [ Addition ]
worker.on 'error', console.error


Lots of them. Probably. I haven't checked though.

npm loves you