File in use, Catch/Try a number of times

File in use, Catch/Try a number of times

am 11.01.2008 15:29:21 von Larry Bud

We have a web service that a client can send XML to, and that XML is
appended to a file on the server for each call.

At night, a separate processing console app will process the XML.

How would you recommend this interaction to occur so the web service
doesn't step on the toes of the processing app and vice versa?

I thought of having the console app move the XML file out of the
current folder and put it somewhere else. The WS will then recreate
the XML file for the next day. But if the WS is accessing the file, I
won't be able to move it. Should I just loop for a certain amount of
time until the file is able to be moved?

Then in the WS, if the file is being moved and is access, do the same?

Re: File in use, Catch/Try a number of times

am 11.01.2008 15:45:39 von mark

"Larry Bud" wrote in message
news:de404a49-866e-4b4e-bb36-ad8a311e72e4@i29g2000prf.google groups.com...

> How would you recommend this interaction to occur so the web service
> doesn't step on the toes of the processing app and vice versa?

Firstly, the absolute last thing I'd do is have a text file on a web server
which can potentially be locked by more than one user - seems like a
disaster waiting to happen...

Instead, every time a client does an upload, I'd create a separate file with
a dynamically created filename - I'd almost certainly construct the filename
based on a combination of the client's unique identifier and a timestamp
e.g. 123-20080111144130.xml or 20080111144130-123.xml. That way you wouldn't
need to worry about file locking or overwriting...

Then I'd set my processing app to run at just after midnight, and design it
so that it polled the folder containing the XML file(s), inspecting the
filename so that it processed only the files where the timetamp portion of
the filename was earlier than the current day, deleting / renaming them
after successful processing...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Re: File in use, Catch/Try a number of times

am 11.01.2008 16:07:29 von Larry Bud

On Jan 11, 9:45=A0am, "Mark Rae [MVP]" wrote:
> "Larry Bud" wrote in message
>
> news:de404a49-866e-4b4e-bb36-ad8a311e72e4@i29g2000prf.google groups.com...
>
> > How would you recommend this interaction to occur so the web service
> > doesn't step on the toes of the processing app and vice versa?
>
> Firstly, the absolute last thing I'd do is have a text file on a web serve=
r
> which can potentially be locked by more than one user - seems like a
> disaster waiting to happen...
>
> Instead, every time a client does an upload, I'd create a separate file wi=
th
> a dynamically created filename - I'd almost certainly construct the filena=
me
> based on a combination of the client's unique identifier and a timestamp
> e.g. 123-20080111144130.xml or 20080111144130-123.xml. That way you wouldn=
't
> need to worry about file locking or overwriting...
>
> Then I'd set my processing app to run at just after midnight, and design i=
t
> so that it polled the folder containing the XML file(s), inspecting the
> filename so that it processed only the files where the timetamp portion of=

> the filename was earlier than the current day, deleting / renaming them
> after successful processing...

Great advice, thank you very much!

Re: File in use, Catch/Try a number of times

am 11.01.2008 16:34:53 von LVP

Do you have to worry about backup issues after midnight?


"Mark Rae [MVP]" wrote in message
news:OLjuhCGVIHA.1208@TK2MSFTNGP05.phx.gbl...
> "Larry Bud" wrote in message
> news:de404a49-866e-4b4e-bb36-ad8a311e72e4@i29g2000prf.google groups.com...
>
>> How would you recommend this interaction to occur so the web service
>> doesn't step on the toes of the processing app and vice versa?
>
> Firstly, the absolute last thing I'd do is have a text file on a web
> server which can potentially be locked by more than one user - seems like
> a disaster waiting to happen...
>
> Instead, every time a client does an upload, I'd create a separate file
> with a dynamically created filename - I'd almost certainly construct the
> filename based on a combination of the client's unique identifier and a
> timestamp e.g. 123-20080111144130.xml or 20080111144130-123.xml. That way
> you wouldn't need to worry about file locking or overwriting...
>
> Then I'd set my processing app to run at just after midnight, and design
> it so that it polled the folder containing the XML file(s), inspecting the
> filename so that it processed only the files where the timetamp portion of
> the filename was earlier than the current day, deleting / renaming them
> after successful processing...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net

Re: File in use, Catch/Try a number of times

am 11.01.2008 17:24:00 von brucebarker

an additional good trick is to create the file with a name like .out,
then after its closed rename to .xml. then the pickup prograg will
not hit open files.

-- bruce (sqlwork.com)


"Mark Rae [MVP]" wrote:

> "Larry Bud" wrote in message
> news:de404a49-866e-4b4e-bb36-ad8a311e72e4@i29g2000prf.google groups.com...
>
> > How would you recommend this interaction to occur so the web service
> > doesn't step on the toes of the processing app and vice versa?
>
> Firstly, the absolute last thing I'd do is have a text file on a web server
> which can potentially be locked by more than one user - seems like a
> disaster waiting to happen...
>
> Instead, every time a client does an upload, I'd create a separate file with
> a dynamically created filename - I'd almost certainly construct the filename
> based on a combination of the client's unique identifier and a timestamp
> e.g. 123-20080111144130.xml or 20080111144130-123.xml. That way you wouldn't
> need to worry about file locking or overwriting...
>
> Then I'd set my processing app to run at just after midnight, and design it
> so that it polled the folder containing the XML file(s), inspecting the
> filename so that it processed only the files where the timetamp portion of
> the filename was earlier than the current day, deleting / renaming them
> after successful processing...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
>