1.3.1 • Published 6 years ago

jackrabbitjs v1.3.1

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

JackrabbitJS

npm version Build Status

JackrabbitJS is a amqplib wrapper built to hide the complexities of messaging protocols. It was built for smaller to midlevel projects that need a simple messaging api that works.

Usage

Installing JackrabbitJS

npm install jackrabbitjs --save

Consumer:

const jackrabbit = require('jackrabbitjs');

const credentials = {
    uri: 'server-uri',
    user: 'jack',
    password: 'rabbitjs'
};

let options = {
    queue: 't',
    ack: true
};

jackrabbit.connect(credentials, (err, connection) => {
    jackrabbit.consume(connection, options, (err, message) => {
        console.log(message.content.toString());
    });
});

Producer:

const jackrabbit = require('jackrabbitjs');

const credentials = {
    uri: 'server-uri',
    user: 'jack',
    password: 'rabbitjs'
};

let options = {
    queue: 't',
    payload: 'ello',
    timeout: 3000
};

jackrabbit.connect(credentials, (err, connection) => {
    if (err) {
        process.exit(1);
    }
    jackrabbit.produce(connection, options);
});

RPC-Consumer:

const jackrabbit = require('jackrabbitjs');

const credentials = {
    uri: 'server-uri',
    user: 'jack',
    password: 'rabbitjs'
};

let options = {
    queue: 't',
    rpc: true
};

jackrabbit.connect(credentials, (err, connection) => {
    jackrabbit.consume(connection, options, (e, message, channel) => {
        if(channel) {
            jackrabbit.reply(message.properties.replyTo, message.properties.correlationId, channel, 'jackrabbitjs');
        }
    });
});

RPC-Producer:

const jackrabbit = require('jackrabbitjs');

const credentials = {
    uri: 'server-uri',
    user: 'jack',
    password: 'rabbitjs'
};

let options = {
    queue: 't',
    payload: 'ello',
    rpc: true,
    exclusive: true,
    timeout: 3000
};

jackrabbit.connect(credentials, (err, connection) => {
    jackrabbit.produce(connection, options, (err, reply) => {
        // do stuff with the message
    });
});

Options:

uri: [the RabbitMQ server uri]
user: If the user is specified in the uri, this is not needed.
password: If the password is specified in the uri, this is not needed.
payload: [the payload sent to the consumer]
function: [function call sent to the consumer]
exclusive: defaults to false,
rpc: defaults to false,
ack: defaults to true,
persistent: defaults to false,
durable: defaults to false,
prefetch: defaults to 1,
timeout: defaults to -1. The connection must be closed manually if a timeout is not specified.

Roadmap

version 1.1

  • basic one way publish
  • basic one way consume

version 1.2

  • consume with acknowledgement and reply
  • publish receives acknowledgement and reply

version 1.3

  • refactor to simplify api

version 1.4

  • broadcast to multiple consumers

miscellaneous

  • documentation
1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago