amqplib-scheduler

0.0.1 • Public • Published

amqplib-scheduler

Easy messages scheduling with amqplib.

This library is based on purposeindustries/node-amqp-schedule ported to use with the amqplib AMQP client library.

Install

npm install amqplib-scheduler

Use with squaremo/amqp.node.

Usage

var amqp   = require('amqplib/callback_api');
var scheduler = require('amqplib-scheduler');
 
//A stablished amqp connection in needed
amqp.connect(function (err, conn) {
  if (err !== null) return bail(err);
 
//Scheduler initialization
  var schedule = scheduler(conn, {prefix: 'qPrefix', separator: '.'});
 
  var date = new Date(Date.now() + 20000);
  schedule('dlExchange', 'dlxRoute', { foobar: '30s ' + new Date()}, 30000, cb);
  schedule('dlExchange', 'dlxRoute', { foobar: '' + date }, date, cb);
}

Options

the scheduler initialization accepts a second optional parameter (options) :

{
    prefix:  [temp queue name prefix, defaults to 'schedule'],
   separator:  [temp queue name separator, defaults to '.'],
    threshold:  [temp queue expires after delay + threshold, defaults to 10000]
}

Package Sidebar

Install

npm i amqplib-scheduler

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • pogui