Skip to content

Repository files navigation

Build Status

node-zeromq

ØMQ bindings for node.js.

Installation

Install zmq package first.

$ npm install zmq

Example

producer.js:

varzmq=require('zmq'),sock=zmq.socket('push');sock.bindSync('tcp://127.0.0.1:3000');console.log('Producer bound to port 3000');setInterval(function(){console.log('sending work');sock.send('some work');},500);

worker.js:

varzmq=require('zmq'),sock=zmq.socket('pull');sock.connect('tcp://127.0.0.1:3000');console.log('Worker connected to port 3000');sock.on('message',function(msg){console.log('work: %s',msg.toString());});

Running tests

Install dev deps:

 $ npm install

Build:

 $ make

Test:

 $ make test

Running benchmarks

Benchmarks are available in the perf directory, and have been implemented according to the zmq documentation: How to run performance tests

In the following examples, the arguments are respectively:

  • the host to connect to/bind on
  • message size (in bytes)
  • message count

You can run a latency benchmark by running these two commands in two separate shells:

node ./local_lat.js tcp://127.0.0.1:5555 1 100000
node ./remote_lat.js tcp://127.0.0.1:5555 1 100000

And you can run throughput tests by running these two commands in two separate shells:

node ./local_thr.js tcp://127.0.0.1:5555 1 100000
node ./remote_thr.js tcp://127.0.0.1:5555 1 100000

About

Node.js bindings to the zeromq library

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages