multimq

0.0.4 • Public • Published

MutiMQ

Wrapper for using different message queue systems, such as: zeromq, axon and hypermq.

Allows use of multiple message queueing systems within this single module, providing a universal set of common commands. Message queues supported:

Installation

From your terminal, requires node.js.

npm install multimq

The zmq module is a binding so it is not installed by default, if you wish to use zmq (zeromq) you will need to install it separately within the multimq folder:

npm install zmq

Options

  • service set a service/socket name
  • mq axon, zmq, hypermq
  • pattern push / pull, pub / sub, req / rep (axon, zmq), chit / chat (hypermq), pub-emitter / sub-emitter (axon), router / dealer (zmq)
  • socket bind, connect, bindSync (zmq)
  • hostname hostname address
  • port host port
  • secure hypermq boolean
  • key hypermq ssl/tls key filename
  • cert hypermq ssl/tls certificate filename
  • apikey hypermq apikey string
  • protocol hypermq amp, ldjson

Events

  • closed when peer closes.
  • error (err) when an un-handled socket error occurs.
  • reconnect attempt when a reconnection attempt is made.
  • connected (any url queries sent as object) when connected to the peer, or a peer connection is accepted.
  • queued (msg) when a message is enqueued, can use to save unsent messages.
  • flushed (total messages) queued when messages are flushed on connection.
  • message (msg) the message received by peer.

Example

bind:

var multimq = require('multimq');
var service = multimq.service();
 
var options = {
  service: 'myService',
  mq: 'hypermq',
  pattern: 'pub',
  socket: 'bind',
  hostname: '127.0.0.1',
  port: 3443,
  secure: false,
  key: __dirname + '/key.pem',
  cert: __dirname + '/cert.pem',
  apikey: 'za91j2bk72f483ap62x',
  protocol: 'amp'
};
 
var myService = new service(options);
console.log('MQ push service bound at: tcp://localhost:5555');
 
setInterval(function(){
  console.log('sending...');
  sock.send('hello world');
}, 500);
 

connect:

var multimq = require('multimq');
var service = multimq.service();
 
var options = {
  service: 'myService',
  mq: 'hypermq',
  pattern: 'sub',
  socket: 'connect',
  hostname: '127.0.0.1',
  port: 3443,
  secure: false,
  apikey: 'za91j2bk72f483ap62x',
  protocol: 'amp',
  rejectUnauthorized: false
};
 
var myService = new service(options);
console.log('MQ pull service connected to: tcp://localhost:5555');
 
myService.on('message', function(msg){
  console.log(msg.toString());
});
 

License

Choose either: MIT or Apache 2.0.

Package Sidebar

Install

npm i multimq

Weekly Downloads

0

Version

0.0.4

License

MIT

Last publish

Collaborators

  • kurunt