Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A node.js implementation of RQueue, includes Worker and Queue
JavaScript
tree: ae150e2f25

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
deps/node-redis
test
.gitignore
Makefile
README
index.js

README

Description
-----------

Node-redis-queue is a simple Redis based message queue for communicating between multiple platforms.
It uses a easy to implement message paradigm within Redis lists.

An example message:

    {
      id: 1,
      payload: 'Some data',
      errors: ['HTTP 404'],
      error_count: 1
    }

Messages are put onto the list with `rpush`, then the client listens for messages with the `blpop` command.

Usage
-----

queue-server.js:

// Require the node-redis-queue
var client = require('./node-redis-queue');

// Create the Queue with a redis server listening on localhost:6379
var user_queue = new client.Queue('user', 'localhost', 6379);

// Add a job to the queue.
user_queue.push('Any JSON.strinify-able data goes in this parameter', function (error, id) {
  // Handle errors
  if (error) throw error;
  // Second parameter is the message/job id.
});

queue-worker.js:

// Require the node-redis-queue
var client = require('./node-redis-queue');

// Create a worker for each queue.
var worker = client.createWorker('user', 'localhost', 6379);

// Setup message event
worker.on('message', function (job) {
  // Process message
  process(job.payload);

  // Listen for next job
  worker.next();
});

// Start listening.
worker.start();
Something went wrong with that request. Please try again.