Node.js job queue backed by MongoDB
Switch branches/tags
Nothing to show
Pull request Compare This branch is 2 commits ahead, 51 commits behind kof:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

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
db = ... an opened node-mongodb-native database
connection = new mojo.Connection db, {}

# 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 ], {}


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