node package manager
We need your input. Help make JavaScript better: Take the 2017 JavaScript Ecosystem survey »


CloudQ Consumer

Build Status

This module is a javascript api wrapper for consuming CloudQ Jobs.


var consumer = require('cloudq-consumer');
  server: 'http://token:secret@localhost:3000/',
  queue: 'foo',
  interval: 2000
}).consume(function(job, complete, log) {
  //Do worker stuff here 
  complete(null,, function() {'done'); } );




config object server - name of the cloudq server (include auth in url) queue - name of the queue to monitor to consume jobs from interval - amount of time in between checks in milliseconds

the constructor returns a consumer instance with the following methods:

  • consume


consume(function(job, complete, [log]) { complete(null, 'success', function() { }); });

The consume method get invoked every time a job is found and returned on the queue.

This is where you can handle your worker processing, the consume method takes a function which will be passed two paramters.

  • job - this is the job object being passed from CloudQ { id: 'XXXXX', klass: 'foo', args: [....] }
  • complete - this is a callback method that takes the following parameters:
    • error - if no error then pass null
    • id - in this param is the job id, so that the complete task can tell cloudq I am finished.
    • [cb] - optional callback incase you want to do additional work after the complete function has been completed...
  • [log] - optional parameter to the bunyan logging system in case you want to log info on your worker


  • Create a new NodeJS Project
mkdir [project]
cd [project]
npm init
  • Install cloudq-consumer module
npm install cloudq-consumer --save
  • Use the example template above to get started.

** Be sure to create a in your project


npm test




The api is straight forward and should remain simple, but all contributions are welcome in the form of pull requests.

Thank You

  • NodeJS Core Team
  • Underscore Team
  • Request Team
  • Flatiron/Nock Team
  • Mocha Team