I have been working with RabbitMQ on .Net for a while already and I don't have much of a problem with it. Now I'm moving to rabbit.js with node.js and I'm not pretty much familiar with it. rabbit.js has a limited documentation. All I know is the basic PUSH/PULL or PUB/SUB. Now I wanted to do REQ/REP and I don't know how do it. Anybody can share some snippet please.
Your reply is greatly appreciated.
Best,
Best Answer
This is perhaps more then you asked for but I have a snipplet (even though it's quite long) for doing RPC using node-amqp instead of REQ/RES with rabbit.js. What I have done is similar to what you could find in the RabbitMQ tutorial about RPC
For the moment the content in the message should be an object (hash) that will get transformed by the amqp module to json.
The AmqpRpc class take an amqp connection when initialized then it should only be a matter of calling makeRequest and wait for a response in the callback. The response have the form of function(err, response) where err might be a timeout error
I'm sorry its not exactly what you asked for but it's maybe close enough. I also posted the code as a gist on github: https://gist.github.com/2720846
Edit: Samples changed to support multiple outstanding requests.
amqprpc.js
A small example on how to use it can be found below. Save both code parts and just run with...
If you don't have a server to provide the reply the request will time out.
client.js
I'll even throw in a sample server for good measure
server.js