Neo Wills wrote:3. I can get the session id from the http request. But how do I convert it back to http request and use to send response back
You can't. You can only send a response when you get a request.
A web app is not like a desktop app that's "always running". A web app only "runs" when a request comes in.
So you have two choices when dealing with long-running processes:
Block and send the response when it's done -- as pointed out, not a good idea.Fire off a thread and return the response immediately.
When the thread completes, store the information in the DB (or wherever else is appropriate). At this point, you do
not have the option of returning a response as there is no request. Besides, by this time, the user is probably off looking at goofy videos on youtube.
What you provide is a means for the user to come back -- at their own good time -- and check the status and results of the operation.