0.2.0 • Published 9 years ago

queue-commander v0.2.0

Weekly downloads
1
License
MIT
Repository
-
Last release
9 years ago

Queue Commander

AMQP for dummies

npm install queue-commander

Usage

var QueueCommander = require('queue-commander');
var qc = new QueueCommander(settings());

function settings() {
    return {
        consumeJobResults: false, // default: true
        prefix: 'staging_', // prepend queue with prefix
    };
}
  1. declare queue (queue-schema.js)

    qc.registerQueue('fruits', {durable: false}); // configure queue here
2. declare channel(s) (queue-schema.js)

  ```javascript
  var apple = qc.channel({name: 'apple', input: 'fruits'}); // RPC
  var orange = qc.channel({name: 'orange', input: 'fruits', output: 'results'}); // remote job
  1. on server (server.js)

    apple.onServer(function(args, done, ack) {
        ack(true);
        setTimeout(function() {
          done(null, 'yummy ' + args.name);
        }, 1000);
    });
  2. on client: remote call (client-rpc.js)

    // register call
    var sendToAppleQueue = apple.onClient();
    // make a call
    sendToAppleQueue({name: 'golden apple'}).then(function(response) {
        console.log(response); // yummy golden apple
    });
  3. on client: remote job (client-job.js)

    // register job
    var sendToOrangeQueue = orange.onClient(function(err, res, next){
        console.log(res); // yummy sweet orange
        next();
    });
    // post a job
    sendToOrangeQueue({name: 'sweet orange'}); // note that callback will not be called
0.2.0

9 years ago

0.0.16

9 years ago

0.0.15

9 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago