简体   繁体   English

如何使用骆驼Apache计时器组件

[英]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. 而不是使用“ 30000”,您可以使用“ 30s”,它更易于阅读。

Check this out . 检查一下

Use timer with pollEnrich 将计时器与pollEnrich一起使用

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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