You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "arda.aydin" <ko...@gmail.com> on 2011/01/23 14:29:11 UTC

Poll a folder and consume files older than x times

Hi,

In my system, there is a folder that i use to put some files to be consumed
by an application which deletes the file after the consume. If the name of
the file is not good for the application, the file is never read and stays
inside folder. 

So i want to poll this folder with a camel route, then consume files which
are older than x times in order to move them inside an error folder and
throw an exception.

What is the best way to do it?
- Filter that checks the lastmodificationdate of the file?
- A polling component which polls twice and chacks the existence of the
file?

I would be glad to have your ideas.
Thank you.


-- 
View this message in context: http://camel.465427.n5.nabble.com/Poll-a-folder-and-consume-files-older-than-x-times-tp3353626p3353626.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Poll a folder and consume files older than x times

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Jan 24, 2011 at 3:53 PM, arda.aydin <ko...@gmail.com> wrote:
>
>
> Hi Claus,
>
> Thanx for the reply.
>
> I need a filter because i must avoid certain files being processed.
> I will not have 2 file consumers "racing" in the same file directory because
> i have only one condition to be applied. Files that do not match will not be
> processed.
> Is there other way to avoid the files being processed except filters??
>

No filtes is a good to use as that's the point. You implement logic to
say yes/no to process the file or not.



> Regards.
>
>
> Claus Ibsen-2 wrote:
>>
>> On Sun, Jan 23, 2011 at 2:29 PM, arda.aydin <ko...@gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> In my system, there is a folder that i use to put some files to be
>>> consumed
>>> by an application which deletes the file after the consume. If the name
>>> of
>>> the file is not good for the application, the file is never read and
>>> stays
>>> inside folder.
>>>
>>> So i want to poll this folder with a camel route, then consume files
>>> which
>>> are older than x times in order to move them inside an error folder and
>>> throw an exception.
>>>
>>
>> What do you need to throw the exception for? Who is to handle that
>> exception?
>>
>>
>>> What is the best way to do it?
>>> - Filter that checks the lastmodificationdate of the file?
>>> - A polling component which polls twice and chacks the existence of the
>>> file?
>>>
>>
>> Using a custom filer allows you to check the file age and thus slurp
>> the old files?
>>
>>
>> You could just have a route which does that
>> from("file:inbox?filer=#myOldFiler").to("file:oldFilles");
>>
>> And to consume the "good" files you can use a filer as will to pickup
>> the new files
>> from("file:inbox?filer=#myGoodFiler").to(whatEverYouWant)
>>
>> A little caveat with this solutions is that you got 2 file consumers
>> "racing" in the same file directory.
>>
>>
>>
>> Another alternative could be to use the Content Based Router.
>> Camel provides the file age as a header so you can use that to
>> determine if its an old file or not
>>
>> from(inbox)
>>   choice
>>      when(oldFilePredicate)
>>            to(file:oldFileds)
>>     end
>>     // this is a good file
>>     to(whatEverYouWant)
>>
>> You can also use the Filer EIP and stop if that makes more sense
>>
>> from(inbox)
>>   filter(oldFilePredicate)
>>        to(file:oldFileds)
>>        stop // dont continue routing as its an old file
>>     end
>>     // this is a good file
>>     to(whatEverYouWant)
>>
>>
>>
>>> I would be glad to have your ideas.
>>> Thank you.
>>>
>>>
>>> --
>>> View this message in context:
>>> http://camel.465427.n5.nabble.com/Poll-a-folder-and-consume-files-older-than-x-times-tp3353626p3353626.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Poll-a-folder-and-consume-files-older-than-a-given-date-tp3353626p3354758.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Poll a folder and consume files older than x times

Posted by "arda.aydin" <ko...@gmail.com>.

Hi Claus,

Thanx for the reply.

I need a filter because i must avoid certain files being processed.
I will not have 2 file consumers "racing" in the same file directory because
i have only one condition to be applied. Files that do not match will not be
processed.
Is there other way to avoid the files being processed except filters??

Regards.


Claus Ibsen-2 wrote:
> 
> On Sun, Jan 23, 2011 at 2:29 PM, arda.aydin <ko...@gmail.com> wrote:
>>
>> Hi,
>>
>> In my system, there is a folder that i use to put some files to be
>> consumed
>> by an application which deletes the file after the consume. If the name
>> of
>> the file is not good for the application, the file is never read and
>> stays
>> inside folder.
>>
>> So i want to poll this folder with a camel route, then consume files
>> which
>> are older than x times in order to move them inside an error folder and
>> throw an exception.
>>
> 
> What do you need to throw the exception for? Who is to handle that
> exception?
> 
> 
>> What is the best way to do it?
>> - Filter that checks the lastmodificationdate of the file?
>> - A polling component which polls twice and chacks the existence of the
>> file?
>>
> 
> Using a custom filer allows you to check the file age and thus slurp
> the old files?
> 
> 
> You could just have a route which does that
> from("file:inbox?filer=#myOldFiler").to("file:oldFilles");
> 
> And to consume the "good" files you can use a filer as will to pickup
> the new files
> from("file:inbox?filer=#myGoodFiler").to(whatEverYouWant)
> 
> A little caveat with this solutions is that you got 2 file consumers
> "racing" in the same file directory.
> 
> 
> 
> Another alternative could be to use the Content Based Router.
> Camel provides the file age as a header so you can use that to
> determine if its an old file or not
> 
> from(inbox)
>   choice
>      when(oldFilePredicate)
>            to(file:oldFileds)
>     end
>     // this is a good file
>     to(whatEverYouWant)
> 
> You can also use the Filer EIP and stop if that makes more sense
> 
> from(inbox)
>   filter(oldFilePredicate)
>        to(file:oldFileds)
>        stop // dont continue routing as its an old file
>     end
>     // this is a good file
>     to(whatEverYouWant)
> 
> 
> 
>> I would be glad to have your ideas.
>> Thank you.
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Poll-a-folder-and-consume-files-older-than-x-times-tp3353626p3353626.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
> 
> 

-- 
View this message in context: http://camel.465427.n5.nabble.com/Poll-a-folder-and-consume-files-older-than-a-given-date-tp3353626p3354758.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Poll a folder and consume files older than x times

Posted by Claus Ibsen <cl...@gmail.com>.
On Sun, Jan 23, 2011 at 2:29 PM, arda.aydin <ko...@gmail.com> wrote:
>
> Hi,
>
> In my system, there is a folder that i use to put some files to be consumed
> by an application which deletes the file after the consume. If the name of
> the file is not good for the application, the file is never read and stays
> inside folder.
>
> So i want to poll this folder with a camel route, then consume files which
> are older than x times in order to move them inside an error folder and
> throw an exception.
>

What do you need to throw the exception for? Who is to handle that exception?


> What is the best way to do it?
> - Filter that checks the lastmodificationdate of the file?
> - A polling component which polls twice and chacks the existence of the
> file?
>

Using a custom filer allows you to check the file age and thus slurp
the old files?

You could just have a route which does that
from("file:inbox?filer=#myOldFiler").to("file:oldFilles");

And to consume the "good" files you can use a filer as will to pickup
the new files
from("file:inbox?filer=#myGoodFiler").to(whatEverYouWant)

A little caveat with this solutions is that you got 2 file consumers
"racing" in the same file directory.



Another alternative could be to use the Content Based Router.
Camel provides the file age as a header so you can use that to
determine if its an old file or not

from(inbox)
  choice
     when(oldFilePredicate)
           to(file:oldFileds)
    end
    // this is a good file
    to(whatEverYouWant)

You can also use the Filer EIP and stop if that makes more sense

from(inbox)
  filter(oldFilePredicate)
       to(file:oldFileds)
       stop // dont continue routing as its an old file
    end
    // this is a good file
    to(whatEverYouWant)



> I would be glad to have your ideas.
> Thank you.
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Poll-a-folder-and-consume-files-older-than-x-times-tp3353626p3353626.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/