Reputation: 23737
I have a Rails app that sends requests to a Node.js app. The node.js app processes the requests and returns to the Rails app.
This is all done synchronously in the Rails app (the app blocks until Node.js returns). However, what I intend to do is make this non-blocking.
I want the Rails app to send a request to the Node.js app and only when the Node.js app returns, the Rails app shows the information to the user via UI (without the request being blocked).
This is the first time I need to do something like this and I'm not being able to know how. I was thinking that if I put the request in a queue (maybe redis pub sub) I could retrieve it using Node.js, process and return again. Would this work?
Also, how do I know which user made the request (I have to return the information processed by the node.js app to him)?
Thank you
Upvotes: 2
Views: 2075
Reputation: 1257
To know which user made the request, pass in the user ID as an argument. If you have no User Id the other option to do this is via IPs but that will get complicated fast.
But what you described sounds like it would work.
If this is your first time, may I suggest looking into this screencast: http://railscasts.com/episodes/271-resque
Upvotes: 1