I have been trying to research if it makes sense to change my state management 
from file system to MSMQ; I haven't seen much on state management out there 
though.  

Basically I have written a real time file transfer system using 
FileSystemWatcher that moves files from different nas locations to our local 
windows server (and vice-verca) and then executes a script in a custom 
procedural scripting language.  

For example, 
if a file is found in location "X" meeting the requirement of say "*.pgp" it is 
copied to a specified destination(s) directory as "*.working"
        I then write out the state file, 

I then rename it to "*.pgp" and write out the state file again, 
        I then delete the original and yes you guessed it... 
        write out a state file... 

the final step is kicking off our script that does PGP decrypt/encrypt, FTP, 
bla bla bla.   

It gets complicated if I have multiple files in a directory, and multiple 
destinations; say a destination and an archive.... I am just don't like my 
architecture for this and can't seem to think of a way to make it better... 
What I need to do is find another person that feels like doing a really harsh 
code review.... :-)  Thanks for the help Dean... as always you are full of 
great suggestions.  The system works great the issue is recoverability if the 
system goes down or there is an issue.  This is my first real-time 
multithreaded application; before this I lived in the response-request paradigm 
of the web.   

Travis D. Falls | Consultant   RAFT.Net   IT | 860.547.4070 | [EMAIL PROTECTED]


-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] Behalf Of Dean Fiala
Sent: Friday, November 18, 2005 8:44 AM
To: [email protected]
Subject: Re: [AspNetAnyQuestionIsOk] File still in use error


Hmm, you have other service or process paying particular attention to
the file system.  A virus scanner perhaps?

You could also try sleeping the threads briefly, though that might
defeat the purpose.  Are you sure you only have one instance of the
app running?  I've scrod myself in similar fashion before.

Another option, is as you suggested to use another queuing mechanism.

Or, though this is a bit messy, you could version your files, and
clean up at your leisure.

First time you save TDF02 in C:\RAFT.NET\Service\State\IDs\TDF02_1.state
then TDF02_2.state, etc.

Your retrieval piece would just have to be smart enough to grab the
latest version of each object.



On 11/18/05, Falls, Travis D (HTSC, CASD) <[EMAIL PROTECTED]> wrote:
> No it is off; thanks for the thoughts Dean.  I am starting to think that the 
> OS simply isn't releasing the files quick enough...
>
> Travis D. Falls | Consultant   RAFT.Net   IT | 860.547.4070 | [EMAIL 
> PROTECTED]
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[EMAIL PROTECTED] Behalf Of Dean Fiala
> Sent: Friday, November 18, 2005 8:12 AM
> To: [email protected]
> Subject: Re: [AspNetAnyQuestionIsOk] File still in use error
>
>
> Go to the Services console.  You can find it the Administrative Tools
> program group.
>
> There is a service called Indexing Service. Stop it and set its
> startup type = manual.
>
> On 11/18/05, Falls, Travis D (HTSC, CASD) <[EMAIL PROTECTED]> wrote:
> > Dean,
> > Thanks for the response... I have been struggling with this for weeks.  I 
> > am currently in development stages and I am running this console 
> > application on my laptop.  I don't know if indexing is turned on... how 
> > would I check?
> >
> > Travis D. Falls | Consultant   RAFT.Net   IT | 860.547.4070 | [EMAIL 
> > PROTECTED]
> >
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[EMAIL PROTECTED] Behalf Of Dean Fiala
> > Sent: Thursday, November 17, 2005 10:29 PM
> > To: [email protected]
> > Subject: Re: [AspNetAnyQuestionIsOk] File still in use error
> >
> >
> > Travis,
> > Do you have the Indexing Service on, on this server?  If so, turning
> > it offf, might solve the problem.
> >
> > On 11/17/05, Falls, Travis D (HTSC, CASD) <[EMAIL PROTECTED]> wrote:
> > > I have the following method in a utility class I created that is 
> > > instantiated via a singleton.  I think begin my file work load that can 
> > > be 100 files... I start 10 threads that do a copy, rename, delete, script 
> > > work load.  During these threads I create files based on the work item's 
> > > ID for example S053R.state with the method below.  Every step of the way 
> > > I call the below method to serialize an object to maintain state incase 
> > > the system goes down or the transfer fails.
> > >
> > > My questions:
> > >
> > > 1.  Why do I keep getting the:
> > > 2005-11-17 14:22:40,305 [2096] ERROR 
> > > com.TheHartford.HTSC.RAFT.FileWatcher.Utilities [(null)] -EXCEPTION: 
> > > Access to the path "C:\RAFT.NET\Service\State\IDs\TDF02.state" is denied. 
> > > System.UnauthorizedAccessException: Access to the path 
> > > "C:\RAFT.NET\Service\State\IDs\TDF02.state" is denied.
> > >    at System.IO.__Error.WinIOError(Int32 errorCode, String str)
> > >    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess 
> > > access,
> > > FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, 
> > > Boolean bFromProxy)
> > >    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess 
> > > access, FileShare share, Int32 bufferSize)
> > >    at System.IO.FileInfo.Create()
> > >    at com.TheHartford.HTSC.RAFT.FileWatcher.Utilities.DoSerialize(String 
> > > Path, String Name, Object o) in 
> > > c:\raft\filewatcher\code\utilities.cs:line 438
> > >
> > > 2.  would it be better to create a state engine using MSMQ instead?
> > >
> > > Any help would be greatly appreciated; I have been struggling with this 
> > > one for a while.  I feel like I am closing everything and I know this is 
> > > the only method and process that creates and deletes these files.
> > >
> > >
> > > public void DoSerialize(String Path, String Name, object o) {
> > >         lock (syncRoot2){
> > >                 try{
> > >                         object j = new object();
> > >                         j = o;
> > >                         DirectoryInfo di = new DirectoryInfo(Path);
> > >                         FileInfo[] finfos = di.GetFiles(Name);
> > >                         for(int i = 0; i < finfos.Length; i++){
> > >                                 FileInfo file = finfos[i];
> > >                                 try{
> > >                                         file.Delete();
> > >                                 }
> > >                                 catch (FileNotFoundException fnfe){
> > >                                         log.Error("FILE NOT FOUND: " + 
> > > fnfe.ToString() + " " + fnfe.Message);
> > >                                 }
> > >                                 catch (IOException fnfe){
> > >                                         log.Error("IO EXCEPTION: " + 
> > > fnfe.ToString() + " " + fnfe.Message);
> > >                                 }
> > >                         }
> > >                         FileInfo fi = new FileInfo(Path + Name);
> > >                         using (Stream myFileStream = fi.Create()){
> > >                                 SoapFormatter serializer = new 
> > > SoapFormatter();
> > >                                 serializer.Serialize(myFileStream, j);
> > >                                 DoGarbageCollection();
> > >                         }
> > >                 }
> > >                 catch (Exception ex){
> > >                 DoMessaging("FWE00017", ex.Message + " " + ex.ToString(), 
> > > GetDateNowDateTime());
> > >                 log.Error("EXCEPTION: " + ex.Message + " " + 
> > > ex.ToString());
> > >         }
> > > }
> > >
> > >
> > > *************************************************************************
> > > This communication, including attachments, is
> > > for the exclusive use of addressee and may contain proprietary,
> > > confidential and/or privileged information.  If you are not the intended
> > > recipient, any use, copying, disclosure, dissemination or distribution is
> > > strictly prohibited.  If you are not the intended recipient, please notify
> > > the sender immediately by return e-mail, delete this communication and
> > > destroy all copies.
> > > *************************************************************************
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> > --
> > Dean Fiala
> > Very Practical Software, Inc
> > http://www.vpsw.com
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> Dean Fiala
> Very Practical Software, Inc
> http://www.vpsw.com
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>


--
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com



 
Yahoo! Groups Links



 




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get fast access to your favorite Yahoo! Groups. Make Yahoo! your home page
http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to