camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean Francois LE BESCONT <jflebesc...@gmail.com>
Subject Re: Camel File Discard empty file
Date Thu, 30 May 2013 10:10:57 GMT
I have play with readLock but :

*changed : (with "**?readLock=changed&readLockTimeout=20000&delete=true") :
doesn't detect empty file.*
*
*
*fileLock : (with "?readLock=fileLock&delete=true" ) generate an exception
on the producer of the file ( in my case an other application)
*
*
*
*
2013-05-30 12:06:33 - [0 - file://C:/Temp/camel/rep1/] route1
          INFO  start process file => file.csv
Exception in thread "main" java.io.IOException: The process cannot access
the file because another process has locked a portion of the file
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:305)
at com.mycompany.camel.spring.bacasable.Start.main(Start.java:19)
*
[...]

rename : (with "?readLock=rename&delete=true" ) generate an exception on
the client :

org.apache.camel.component.file.GenericFileOperationFailedException: Error
renaming file from C:\Temp\camel\rep1\file.csv to
C:\Temp\camel\rep1\file.csv.camelExclusiveReadLock
at
org.apache.camel.component.file.FileOperations.renameFile(FileOperations.java:72)[camel-core-2.11.0.jar:2.11.0]
[...]

That is with I have developed my own filter as you suggest.


2013/5/30 Claus Ibsen <claus.ibsen@gmail.com>

> Hi
>
> It does, see the readLock option
> http://camel.apache.org/file2
>
> On Thu, May 30, 2013 at 10:24 AM, Jean Francois LE BESCONT
> <jflebescont@gmail.com> wrote:
> > Hi,
> >
> > I undig an old point (
> >
> http://camel.465427.n5.nabble.com/Camel-File-Discard-empty-file-td472234.html
> > )
> >
> > My camel application wait file send from a tierce application ( which is
> > generate from a file:stream by an other application) and has to process
> it
> > and delete it after.
> >
> > The file can be empty or big (more than 1Go). The big size of the file
> > required that the from wait for the end of the write before to process it
> > and I have to manage in the same time empty file.
> >
> > I have started with a :
> >
> >
> from("file://C:/Temp/camel2/in/?filter=#lockFilter&delay=2000&delete=true")
> > .log("start process file => ${file:name}")
> > .to("file://C:/Temp/camel2/out/?fileName=out.csv")
> > .log("end process file => ${file:name}")
> > .end();
> >
> > With a lockFilter :
> >
> > public class LockFilter<T> implements GenericFileFilter<T> {
> >
> > @Override
> > public boolean accept(GenericFile<T> genericFile) {
> >
> > File currentFile = (File) genericFile.getFile();
> >
> > // try to rename the current file
> > if (currentFile.renameTo(currentFile)) {
> > return true;
> > } else {
> > return false;
> > }
> > }
> > }
> >
> > I am a little suprised that camel doesn't manage it " natively " , is
> there
> > a other solution ?
> >
> > Thanks !
> >
> > Jeff
>
>
>
> --
> Claus Ibsen
> -----------------
> www.camelone.org: The open source integration conference.
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message