Commit 6d8b509d authored by project's avatar project

--no commit message

--no commit message
parent 1df8592f
var amqp = require('amqplib/callback_api');
var args = process.argv.slice(2);
if (args.length == 0) {
console.log("Usage: rpc_client.js num");
process.exit(1);
}
amqp.connect('amqp://bigmaster.igridproject.info', function(err, conn) {
conn.createChannel(function(err, ch) {
ch.assertQueue('', {exclusive: true}, function(err, q) {
var corr = generateUuid();
var num = parseInt(args[0]);
console.log(' [x] Requesting fib(%d)', num);
ch.consume(q.queue, function(msg) {
if (msg.properties.correlationId == corr) {
console.log(' [.] Got %s', msg.content.toString());
setTimeout(function() { conn.close(); process.exit(0) }, 500);
}
}, {noAck: true});
ch.sendToQueue('rpc_queue',
new Buffer(num.toString()),
{ correlationId: corr, replyTo: q.queue });
});
});
});
function generateUuid() {
return Math.random().toString() +
Math.random().toString() +
Math.random().toString();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment