nyply

0.0.1 • Public • Published

Nyply

An extremely simplistic Request/Reply module built on top of AMQP.JS. At the moment, Nyply focuses more on the request experience than it does on the response experience.

Installation

$ npm install nyply

Quick Start

var connection = amqp.createConnection({
  host: 'host',
  port: 5672,
  login: 'login',
  password: 'password'
});

connection.on('ready', function () {
  var nyply = new (require('nyply'))(connection);
  nyply.call('queue', { payload: 'message' }, function response(err, response) {
  	console.log(response);
}, 2000);
});

var responseConnection = amqp.createConnection({
  host: 'host',
  port: 5672,
  login: 'login',
  password: 'password'
})

responseConnection.on('ready', function () {
    responseConnection.queue('queue', { 'durable': false, 'autoDelete': true }, function (q) {
        q.subscribe(function (message, headers, deliveryInfo, m) {
            responseConnection.publish(m.replyTo, { response: "OK", index: message.index }, {
                contentType: 'application/json',
                contentEncoding: 'utf-8',
                correlationId: m.correlationId
            });
        });
    });
});

Running Tests

To run the test suite, first set the following enviromental variables.

  • NYLOGIN The username to use in the connection
  • NYPASSWORD The password to use in the connection
  • NYHOST The host to use in the connection

Invoke the following command within the repo, installing the development dependencies:

$ npm install

Readme

Keywords

none

Package Sidebar

Install

npm i nyply

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • choudeshell