kimbu
v0.5.1
Published
Message bus providing pub/sub and req/res style of messaging over pluggable transports.
Downloads
8
Maintainers
Readme
kimbu
Author: Kurt Pattyn.
Kimbu is a message bus framework that implements publish-subscribe and request-response messaging patterns. It abstracts away from the underlying message transport by using pluggable messaging transport providers. Currently, only a RabbitMQ messaging transport provider has been implemented.
Motivation
Implementing publish-subscribe and request-response messaging patterns using existing transports
(e.g. AMQP, WebSockets), requires some extensive boilerplate code.
Using RabbitMQ for instance, to implement a publish-subscribe messaging pattern one needs to setup a
fanout exchange and bind the consumers via queues to that exchange.
For the request-response style of messaging, a reply queue needs to be set up and messages must be
tagged with a correlation-id
and replyTo
field. When messages return they must be matched to the
request using the correlation-id
.
Although not difficult, this requires a lot of boilerplate code.
Installation
$ npm install kimbu
or
$ npm install kimbu --production
for a production only installation (no tests, documentation, ...).
Supported Node Versions
Kimbu
supports Node
versions 0.12 and later.
To use Kimbu
with Node
versions < 4.0, you must start node
with the --harmony
flag.
Usage
var Client = require("kimbu").Client;
var Transport = require("kimbu").Transport;
var RabbitMQTransport = Transport.providers.RabbitMQTransport;
var rmq = new RabbitMQTransport(); //use default options
var client = new Client("client1", rmq, function(err) {
client.on("calculator.add", function(parameters, next) {
var result = parameters.reduce(function(prevVal, curVal) {
return prevVal + curVal;
});
next(result);
});
client.on("buttonPushed", function(parameters, next) {
console.log("Button %s pushed.", parameters);
next();
});
client.start(function(err) {
client.request("calculator.add", [1, 2, 3, 4, 5], function(err, reply) {
console.log("The sum of 1, 2, 3, 4 and 5 is", reply);
});
client.publish("buttonPushed", "Enter");
});
});
Tests
Unit Tests
$ npm test
Unit Tests with Code Coverage
$ npm run test-cov
This will generate a folder coverage
containing coverage information and a folder coverage/lcov-report
containing an HTML report with the coverage results.
$ npm run test-ci
will create a folder coverage
containing lcov
formatted coverage information to be consumed by a 3rd party coverage analysis tool. This script is typically used on a continuous integration server.
Benchmarks
$ npm run benchmark
Checkstyle
Executing
$ npm run check-style
will run the jscs
stylechecker against the code.
Static Code Analysis
Executing
$ npm run code-analysis
will run jshint
to analyse the code.
Code Documentation
Executing
$ npm run make-docs
will run jsdoc
to create documentation.