var http = require('http');
var connect = require('amqp').createConnection('amqp://localhost');
connect.on('ready', function() {
var ex = connect.exchange('ex', {type: 'fanout'});
q.on('queueDeclareOk', function(args) {
q.bind('server_exchange', 'server_exchange');
q.on('queueBindOk', function() {
q.subscribe(function(message) {
if( message.data.toString() == "ok")
{
(function(i) {
for (var i = 0; i < 5; i++) { /*blocking in this area */
var numExchange = connect.exchange('test'+i.toString(), {type: 'fanout'});
numExchange.bind('ex', 'key'+i, function(result) {
});
}
})(i);
}
});
});
});
});
http.createServer(function(req, res){
}).listen(8080, 'localhost');
console.log('Server running at
http://localhost:8080/');