You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dwarakart <dw...@gmail.com> on 2015/11/13 13:29:36 UTC

Pick latest file and ignore the remaining files for a given date

Hi All,

I have a camel route that is a file consumer and relies on the include
format with date and filename in it. The actual files arrive with an
additional timestamp. The camel route is started and stopped dynamically.
When the camel route starts, i need to pick the latest file which i can
achieve using sortBy=reverse:file:modified. 

The problem is that I need to process only the latest file
Ex: 
from("file:{srcDir}?include=.*[0-9]{8}_[0-9]{6}_fileName.*")
.bean("myBean", "myProcessMethod");

Sample file names
20141105_063012_fileName.txt
20141105_123012_fileName.txt

In this scenario, I wish to process only 20141105_123012_fileName.txt and
ignore the file 20141105_063012_fileName.txt. 

Please suggest the best approach. 

Thanks
Dwaraka



--
View this message in context: http://camel.465427.n5.nabble.com/Pick-latest-file-and-ignore-the-remaining-files-for-a-given-date-tp5773806.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Pick latest file and ignore the remaining files for a given date

Posted by dwarakart <dw...@gmail.com>.
Awesome. Thanks a lot Claus for the quick response



--
View this message in context: http://camel.465427.n5.nabble.com/Pick-latest-file-and-ignore-the-remaining-files-for-a-given-date-tp5773806p5773826.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Pick latest file and ignore the remaining files for a given date

Posted by Claus Ibsen <cl...@gmail.com>.
You can use the filter eip, and then if the batch index == 1 then only
call the bean

from
   filter batch index == 1
      bean
   end



On Fri, Nov 13, 2015 at 1:29 PM, dwarakart <dw...@gmail.com> wrote:
> Hi All,
>
> I have a camel route that is a file consumer and relies on the include
> format with date and filename in it. The actual files arrive with an
> additional timestamp. The camel route is started and stopped dynamically.
> When the camel route starts, i need to pick the latest file which i can
> achieve using sortBy=reverse:file:modified.
>
> The problem is that I need to process only the latest file
> Ex:
> from("file:{srcDir}?include=.*[0-9]{8}_[0-9]{6}_fileName.*")
> .bean("myBean", "myProcessMethod");
>
> Sample file names
> 20141105_063012_fileName.txt
> 20141105_123012_fileName.txt
>
> In this scenario, I wish to process only 20141105_123012_fileName.txt and
> ignore the file 20141105_063012_fileName.txt.
>
> Please suggest the best approach.
>
> Thanks
> Dwaraka
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Pick-latest-file-and-ignore-the-remaining-files-for-a-given-date-tp5773806.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2