Server LOGIC callback to webapp

Server LOGIC callback to webapp

  

I have a LOGIC module that takes a couple seconds up to 30 seconds to complete.

I need a way for the LOGIC module running on the server to "message back" to the web app telling the webapp what "% complete" the LOGIC module is. 


That way, I could have a progress bar or some other display that shows the user the progress changing as they wait.


Suggestions on how to do this?

Hi Bruce,

The best way to make server to browser communication is to use websockets but that might involve a little bit of work.

Can you make an educated guess of the time it will take and emulate progress on the client side?

Is this a mobile or web-responsive app?

Joao, it is a web-responsive app.

The progress widget on the web app would need to be updated at least once per second.

Stuck ...

Is the progress bar mission critical or faking the progress would be acceptable?

I can handle some degree of faking it ... you see, what I am processing is sets of files containing a number of records.

They typical UPLOAD-PARSE-PROCESS-LOAD type pattern. Sometimes there is 1 file with only a few records which are done instantly ... but there could be tens of files containing hundreds of records.

I need some way of showing progress so the user doesn't think the app is stuck.

What "fake" ideas do you have? I would be willing to try it for sure.

What about this:

Launch a timer that does the heavy work. Create a database entity to store the progress of each task. Check the task progress from time to time using a client-side javascript timer (you decide the appropriate interval here but have in mind that this might affect server availability). At the end discard the task record.

Thanks Joao, I am considering this approach. I've only used timers for non-human batch jobs, so I will need to learn how to use timers within a web session.

Also, on the client-side JS, any suggestions on a widget or code that would get me started?

I'm not sure how I would initiate essentially an AJAX call every second or so ... 

On web-responsive you can use an unescaped expression with some javascript code to run the timer (tip: setInterval & clearSetInterval). That timer will click on an hidden button that checks the progress against the server.