On Mon, 10 Mar 2014 21:21:51 GMT, Craig Dillabaugh wrote:

In an application I am developing I have a process, initiated by the client, that can run for a considerable length of time (perhaps 10 minutes or more). However rather than have my client application wait around for the server response, I want to simply send a 'OK, I've started the work" message, and let the client check in later to view any results.

My attempt to do this looks like this:

void longProcess(HTTPServerRequest req, HTTPServerResponse res) {
   
    //Do a bit of work.

    res.bodyWriter.write( "{\"process\": \"started\"}" );    
    res.bodyWriter.finalize();

    //Do a lot of work.
}

My initial idea was that the JSON message returned to the client would contain the info. it needed to follow up on progress completing the process.

However, it seems that the message written to res.bodyWriter is not returned to the client until my 'longProcess' function terminates.

Is there any way to achieve what I am trying to do? Alternately, I am happy to hear of any better approaches to dealing with this problem.

You can do "a lot of work" in a separate task started in longProcess and check if that task is finished when the client checks back again.