Hi,
I have a similar problem with the generated output files.
Tried the bean way:
public String generateFileName(final File file)
and
public String generateFileName(final File file, final Exchange exchange)
and
public String generateFileName(final GenericFile<File> genericFile,
final Exchange exchange)
The Problem is that, either way, at the point where my bean is called,
only the in message of the exchange is initialized.
So my bean is called with the input file and I don't see how to obtain
the output file to check if the file already exists.
Of course I could make my bean aware about the output path with an
additional bean property, but this would not be a reliable solution.
Ideas?
Hi
Camel does not have any existing option for this.
You can use a java bean to compute the number yourself
http://camel.apache.org/file-language.html
You can just use the JDK File API to check if the file exists, if it
does, then increment the number, and try again.
Until you find a "free number".
On Mon, Sep 26, 2011 at 11:41 AM, nilsoni<[email protected]> wrote:
Hi,
In File component URI, I have specified "moveFailed=..." option. Now
whenever there is any error, file is moved to error folder. I have a
requirement where files with same name are provided to input endpoint of
file component and if all of them are failing one by one due to any reason,
they should not be overridden in /error folder. Instead, it should be
written in /error folder with some index appended to it. So for example,
I have provided abc.txt to File input endpoint 5 times, on error, there
should be 5 files in error folder with following name.
abc1.txt
abc2.txt
abc3.txt
abc4.txt
abc5.txt
Again, this should be done by camel and not by me by writing some index
number in header as i may not be knowing what was the last index used
(application may be shutdown in between multiple runs of flow mentioned
above). Is there any uri option in camel which does this automatically?
--
View this message in context:
http://camel.465427.n5.nabble.com/Appending-index-number-in-file-name-written-in-error-folder-by-File-component-tp4840768p4840768.html
Sent from the Camel - Users mailing list archive at Nabble.com.