Commit c1d15ed5 authored by Kamron Aroonrua's avatar Kamron Aroonrua 💬

corr

parent 9f476ab2
...@@ -27,7 +27,7 @@ function RPCCaller(config) ...@@ -27,7 +27,7 @@ function RPCCaller(config)
ch.responseEmitter = new EventEmitter(); ch.responseEmitter = new EventEmitter();
ch.responseEmitter.setMaxListeners(0); ch.responseEmitter.setMaxListeners(0);
ch.consume(REPLY_QUEUE , ch.consume(REPLY_QUEUE ,
(msg) => { console.log('reply consumee to ' + msg.properties.correlationId); ch.responseEmitter.emit(msg.properties.correlationId, JSON.parse(msg.content.toString()))}, (msg) => { console.log(msg); ch.responseEmitter.emit(msg.properties.correlationId, JSON.parse(msg.content.toString()))},
{noAck: true}); {noAck: true});
self.opened = true; self.opened = true;
...@@ -50,7 +50,7 @@ RPCCaller.prototype.call = function(req,cb){ ...@@ -50,7 +50,7 @@ RPCCaller.prototype.call = function(req,cb){
self.ch.responseEmitter.once(corr, (resp)=>{ self.ch.responseEmitter.once(corr, (resp)=>{
cb(null,resp); cb(null,resp);
}); });
self.ch.sendToQueue(self.name, new Buffer(JSON.stringify(req)), { corr, replyTo: REPLY_QUEUE }) self.ch.sendToQueue(self.name, new Buffer(JSON.stringify(req)), { correlationId: corr, replyTo: REPLY_QUEUE })
}); });
function generateUuid() { function generateUuid() {
......
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