I have a web server written in Node JS running on Heroku. The server has a web server process and a worker process. The web server successfully sends messages to the worker via a RabbitMQ queue; the worker successfully returns the processed data to the web server. I use a randomly generated Uuid to track the messages and ensure the right message is paired up with the right original message.
In a separate project, I have the client (website) successfully communicating with the web server. Now, I need to put the two together.
How can I make it so:
- Client sends a HTTP POST.
- Web server receives the request and passes the request into the message queue.
- Worker processes the request and returns to the web server.
- Web server returns the correct data to the client so the client can associate the response with the original request.
Step 4 is where I'm stuck. I think I read somewhere that the client should continuously poll (HTTP POSTs?) the web server until it's data is ready. I think I need to respond to the client after step 1 so the request doesn't time out. Any ideas/advice appreciated!
