0.2.0 • Published 8 years ago

queue-commander v0.2.0

Weekly downloads
1
License
MIT
Repository
-
Last release
8 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

8 years ago

0.0.16

8 years ago

0.0.15

8 years ago

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago