Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including commnq with all npm packages installed. Try it out:

var commnq = require("commnq")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

commnq v0.2.1

Node.js Commnq library with handlers for AMQP messages.

   ______                                ____
  / ____/___  ____ ___  ____ ___  ____  / __ \
 / /   / __ \/ __ `__ \/ __ `__ \/ __ \/ / / /
/ /___/ /_/ / / / / / / / / / / / / / / /_/ /
\____/\____/_/ /_/ /_/_/ /_/ /_/_/ /_/\___\_\

CommnQ.js

CommnQ implementation for Node.js

CommnQ was originally a Python script for monitoring GLUE2 AMQP messages for TACC's resource monitoring and information framework. It was since ported to node.js and the handler mechanism abstracted. Three handlers are implemented as useful extension points for developing customized message handlers.

CommnQ.js is build on top of the node-amqp by @postwait.

Documentation

Setting up a CommnQ server

Setting up a server is easy! Just create a new commnq object and pass it and object with connection parameters for the AMQP host. These parameters are in the same format as for node-amqp. Finally, call connect(callback) where callback is a function that will be executed after the AMQP handshake has completed.

var Commnq = require('commnq');

var readyCallback = function() {
  console.log('CommnQ ready!');
};

var server = new Commnq({
  host: 'amqp.example.com'
  , port: 5672
  , login: 'guest'
  , password: 'guest'
  });

server.connect(readyCallback);

Registering a handler

You should register you handlers inside the ready callback for the CommnQ connection.

var server = new Commnq(params);
server.connect(function() {
  server.registerHandler(new Commnq.Handlers.DefaultHandler({
    exchange: 'default'
  }));
});

You can see an example custom handler in example/example.js.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free