views:

82

answers:

2

I have an application that scans an input directory every five seconds and when a job (i.e. file) is placed in the directory the application reads it, processes it and outputs another file(s) in an output directory.

My question is, If I wanted to put a web based front end on this application, how would I wait for the processing to be complete?

  • User submits job
  • job is placed in input directory
  • ......What am I doing on the web page here?
  • processing occurs
  • output file is generated
  • ......How do I know that the job is finished?

The two solutions I came up with were:

  • poll output directory every x seconds from the webpage
  • use ajax to poll a webservice or webpage that reports back whether the output file is present

Is there a better design for the server? In other words, how would TCP or Named Pipes help in this situation? (Cannot use remoting due to a DCOM object.)

A: 

I don't think that Named Pipes are going to make it any easier to get the web client to poll automatically, but it might make the server better able to notify another process that the conversion has completed--and ultimately queue a message to the web browser.

You can try having the web client poll every few seconds to see if the file process has completed, alternatively you could have something like Juggernaut "push" commands out to the page. Juggernaut works using Flash to open a socket on the web browser that continually feeds JavaScript from the server. It could be responsible for sending a command to alert the browser that the file has completed and then issue a redirect.

Nolte Burke
A: 

A solution we have done commercially in the past is basically the daemon writes to a log (typically DB), with a date/time stamp, about what its doing, and the web frontend just shows the latest X amount of entries from the log, with a little toggle to hide all of the "Looked in directory, no file found" messages, worked fairly well, we upgraded it later on with AJAX (Timer that reloaded every 20 seconds).

pzycoman
I hope that made sense, its like 2:30am here, iv been up for 19 hours :)
pzycoman
Thanks pzycoman, that is another solution I had in mind and will probably work for this application.