You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Ole Andreas Hegle <he...@businesscape.no> on 2007/09/26 15:51:28 UTC

File-component will not find new files and lock does not work

Hi everybody

I am using Camel 1.1.0, and have discovered an error in the file component.

When using the file-component without any options like this:
from("file://C:/Test/temp/testfolder").process(new TestFileProcessor());

Everything works according to specification

However...

When I add locking = false like this
from("file://C:/Test/temp/testfolder?lock=false").process(new 
TestFileProcessor());

The files found are still locked (as they are copied to the .camel 
directory.)

If I use the noop=true-option like this
from("file://C:/Test/temp/testfolder?noop=true").process(new 
TestFileProcessor());
The file-component will only find files which are present in directory 
at first scan, not files copied into directory after startup

If I use both lock and noop like this
from("file://C:/Test/temp/testfolder?lock=false&noop=true").process(new 
TestFileProcessor());

The locking-option works fine (the file is not copied to .camel 
sub-directory), however, only the component only finds files present at 
startup, it does not find files copied to the directory after initial 
poll is not detected.


So, for me it seems like there is a problem with the lock-option when 
lock is used as the only parameter, and there is a problem with the 
noop-option (as it only reads files on first scan)

Have anybody the same experience or can anybody help me to sort this out?

Regards. Ole Andreas Hegle, Businesscape AS


However, I would


Re: File-component will not find new files and lock does not work

Posted by Ole Andreas Hegle <he...@businesscape.no>.
Hi Again

The error seems to be in 
org.apache.camel.component.file.FileConsumer.java on the pollFile-method

If a file is copied in to the monitored directory, and the file has a 
modifies-timestamp which is older than the lastPollTime, it will not be 
processed.
(This can be solved by remembering the name and modification time of 
processed files, and process files which is not in this list)



Code with error is below

Regards
Ole Andreas Hegle
Businesscape AS

protected void pollFile(final File file) {
        if (!file.exists()) {
            return;
        }
       if (isValidFile(file)) {
            // we only care about file modified times if we are not 
deleting/moving files
            if (endpoint.isNoop()) {
                long fileModified = file.lastModified();
                if (fileModified <= lastPollTime) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Ignoring file: " + file + " as 
modified time: " + fileModified + " less than last poll time: " + 
lastPollTime);
                    }
                    return;
                }
            } else {
                if (filesBeingProcessed.contains(file)) {
                    return;
                }
                filesBeingProcessed.put(file, file);
            }

Ole Andreas Hegle wrote:
> Hi everybody
>
> I am using Camel 1.1.0, and have discovered an error in the file 
> component.
>
> When using the file-component without any options like this:
> from("file://C:/Test/temp/testfolder").process(new TestFileProcessor());
>
> Everything works according to specification
>
> However...
>
> When I add locking = false like this
> from("file://C:/Test/temp/testfolder?lock=false").process(new 
> TestFileProcessor());
>
> The files found are still locked (as they are copied to the .camel 
> directory.)
>
> If I use the noop=true-option like this
> from("file://C:/Test/temp/testfolder?noop=true").process(new 
> TestFileProcessor());
> The file-component will only find files which are present in directory 
> at first scan, not files copied into directory after startup
>
> If I use both lock and noop like this
> from("file://C:/Test/temp/testfolder?lock=false&noop=true").process(new 
> TestFileProcessor());
>
> The locking-option works fine (the file is not copied to .camel 
> sub-directory), however, only the component only finds files present 
> at startup, it does not find files copied to the directory after 
> initial poll is not detected.
>
>
> So, for me it seems like there is a problem with the lock-option when 
> lock is used as the only parameter, and there is a problem with the 
> noop-option (as it only reads files on first scan)
>
> Have anybody the same experience or can anybody help me to sort this out?
>
> Regards. Ole Andreas Hegle, Businesscape AS
>
>
> However, I would
>