It may be desirable to avoid file lock issue. If you’re trying to pick up a file while another process is still writing it, then there is a fairly straight-forward approach that has been covered on these forums a few times.
-
Polling process looks for files that match a pattern. For example, all *.dat files. Or any file not starting with X, as another example.
-
Process that is dropping off the file writes the file using a pattern that is not being polled for. For example, foobar.tmp or Xfubar.xml.
-
When the file write is complete, rename the file to a name that matches the pattern being polled. For example, foobar.dat or fubar.xml.
-
The poller will now pick up the files on the next run, with no chance of conflicting with a file still being written to/locked.
This approach works on any OS (file rename are atomic) and is effective whether picking up from a local drive, a network share or an FTP server. You can also get a little sophisticated with the rename–a rename can move the file to another directory too. So you might have a temp directory for process X to write the file, then process X renames it to move to the polling directory (need to be a bit careful on this one–works only if the two directories are on the same physical device).
Hope this helps.
#Flow-and-Java-services#Integration-Server-and-ESB#webMethods