Skip to content

Instantly share code, notes, and snippets.

@bcg
Created April 6, 2011 22:45
Show Gist options
  • Save bcg/906701 to your computer and use it in GitHub Desktop.
Save bcg/906701 to your computer and use it in GitHub Desktop.
Node + ZeroMQ + Redis
var zmq = require('zeromq');
s = zmq.createSocket('push');
s.connect('tcp://127.0.0.1:15000');
while (true) { // ZOMG he did it again!
s.send(new Buffer("test"));
}
var zmq = require('zeromq'),
util = require('util'),
redis = require("redis"),
client = redis.createClient();
s = zmq.createSocket('pull');
var count = 0;
var time = null;
s.bind('tcp://127.0.0.1:15000', function(err) {
if (err) throw err;
s.on('message', function(data) {
client.lpush('q', data.toString());
count++;
if (count == 1) {
time = new Date();
}
if ((count % 10000) === 0) {
var t = new Date();
console.log('T: ' + ((t-time)/1000));
time = t;
}
});
util.puts('Server is up ...');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment