I need a trigger

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I wrote a simple Web Service. It Consumes a single String, writes it to a
text file on the hard drive, and returns a success. Now I need a trigger
that will start the program that processes the file.

I could make a routine that checks for new files every so many seconds, but
that uses too much of the machines resources. Any ideas?
 
Why would that take a lot of resources?

I'd just create a console app that you leave running which does a
Thread.Sleep() for some seconds and then scans for new files. I would use a
time interval that's no more frequent than necessary. Once it's debugged,
I'd turn it into a Windows Service.

Alternately, you could create a Windows Service that sits idle waiting for
your Web Service to notify it that it has received something to process.
Then you wouldn't have to scan for anything. Indeed, your web service could
simply avoid writing to a file at all, and pass the string it receives along
to this other process, if the string isn't too big.

--Bob
 
I thougth about letting the Web Service do all the work prior to sending the
'success'. But I have seen and tested another web service that did just that
very thing and as long as no more than 5-10 transactions per minute were sent
every thing worked great (a lot of behind the scenes processing).

This Web service can receive strings from @ 10 characters to @ 100 k
characters. It has to search the string and react to what it finds. It
needs to be able to handle incomming messages of 1 per hour up to 100 per
second.

I thought that if I dumped the string into a text or xml file in a direcory,
that would solve my acceptance speed problem and then I could process the
files at the programs lesure.
 
Well I agree, you should decouple the receipt of the data from the
processing of the data. You could dump them into a folder or into MSMQ and
process them "at leisure", as you suggest. You could also pass them to some
kind of Remoting server that would manage threads and/or still other servers
to do the work while continuing to listen for more "incoming" from the Web
Service.

Done properly, none of these solutions should be inherently slow.

--Bob
 
FileSystemWatcher is a good idea, in fact I went to MSDN and printed the
instructions for FileSystemWatcher.Created Event. Now all I have to do is
figure it out. As you may have guessed, C# is not my primary language. But
it is fun to write.

John
 
Back
Top