Last active
December 18, 2015 21:33
-
-
Save derekcollison/a6a40e009f33a032fc06 to your computer and use it in GitHub Desktop.
Many Subscriptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/* jslint node: true */ | |
'use strict'; | |
var nats = require ('../lib/nats.js').connect('nats://demo.nats.io:4222'); | |
var cuid = require('cuid'); | |
nats.on('error', function(e) { | |
console.log('Error [' + nats.options.url + ']: ' + e); | |
process.exit(); | |
}); | |
nats.on('close', function() { | |
console.log('CLOSED'); | |
process.exit(); | |
}); | |
nats.on('connect', function() { | |
var subs = 2000000; | |
var hash = 1000; | |
console.log('starting ' + subs + ' subscriptions'); | |
for (var i=0; i<subs; i++) { | |
var sub = 'DEVICE.' + cuid() + '.OUT'; | |
nats.subscribe(sub); | |
if (i % hash === 0) { | |
process.stdout.write('#'); | |
} | |
} | |
nats.flush(function() { | |
console.log('\ndone') | |
console.log('<CTRL-C> to quit'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment