camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: De-duplicate route file name?
Date Fri, 17 May 2013 07:33:17 GMT

You can use the move option on the Camel file consumer, and then use a
bean to calculate the file name.


<bean id="myFileCalculatorBean" class=...

And in the bean has a single method

public String calculateFileName(@Header(Exchange.FILE_NAME) String
existingName) {
  // check if the file exists, and if so, then do your - number trick
to find a "free" name

On Thu, May 16, 2013 at 5:04 PM, Peter Hilton <> wrote:
> On 16 May 2013, at 12:23, Peter Hilton <> wrote:
>> I’m using Camel to process files, and need to save a copy of each incoming file
to an 'archive' directory. In addition, if another file arrives with the same name as an earlier
file, I must add this to the archive with a different file name and not overwrite an existing
archive file.
> I'm currently hoping to do it like this:
>         wireTap("file:///archive?fileName=${date:now:yyyy/DDD}/${file:name}", archiveFileNameProcessor)
> … where archiveFileNameProcessor is a Processor that modifies the file name (to avoid
overwriting existing files).
> How can I parse the URL in my processor to get today’s path, e.g. archive/2013/136?
The processor to check this directory for existing files, in order to calculate the next file
name in the sequence, for duplicate input file names.
> Peter

Claus Ibsen
----------------- The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Twitter: davsclaus
Author of Camel in Action:

View raw message