简体   繁体   中英

How to use Camel Apache Timer Component

So currently, the only thing that we can work out is to simply transfer one file to another folder. Like so:

from("file://C:/Users/Me/Desktop/FolderA?noop=true")
    .to("file://C:/Users/Me/Desktop/FolderB");

However, when I try to add the complexity of the timer component, it just does not make sense to me. I keep getting "Cannot write null body to file" exception.

The code I try to write for the timer Component is like so:

from("timer://file://C:/Users/Me/Desktop/FolderA?period=30000")
    .to("file://C:/Users/Me/Desktop/FolderB");

Have you tried:

from("timer://file://C:/Users/Me/Desktop/FolderA?fixedRate=true&period=30s")
    .to("file://C:/Users/Me/Desktop/FolderB");

And instead of using "30000" you could use "30s" which is more friendly to read.

Check this out .

Use timer with pollEnrich

from("timer://foo?period=30000")
   .pollEnrich("file://C:/Users/Me/Desktop/FolderA?noop=true")
   .to("file://C:/Users/Me/Desktop/FolderB");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM