我不知道是否有一种方法可以让骆驼做什么,我需要的是如下定期处理一些输入:如何使用Apache的骆驼
“定期从一些源中读取数据(比方说,一个文件),做一些处理,并写到其他地方“
我想出了如何做所有减去”周期性“部分。我知道如何使用Quartz或Timer触发路线。但是,当我使用那些零件已经被拿走,所以我不能再改变身体。
有什么建议吗?
我不知道是否有一种方法可以让骆驼做什么,我需要的是如下定期处理一些输入:如何使用Apache的骆驼
“定期从一些源中读取数据(比方说,一个文件),做一些处理,并写到其他地方“
我想出了如何做所有减去”周期性“部分。我知道如何使用Quartz或Timer触发路线。但是,当我使用那些零件已经被拿走,所以我不能再改变身体。
有什么建议吗?
你可以用定时器/石英启动它,然后使用一个content enricher或polling consumer
//using timer/pollEnrich to populate the body with the polling results
from("timer://foo?period=5000")
.pollEnrich("file:inbox")
.to("file:outbout");
//using time/polling consumer bean for more flexibility and multiple polling
from("timer://foo?period=5000")
.bean(myPollingConsumerBean, "doIt");
public static class MyPollingConsumerBean {
...
public void doIt() {
while (true) {
String msg = consumer.receiveBody("file:inbox", 3000, String.class);
if (msg == null) {
break;
}
producer.sendBody("file:outbox", msg);
}
}
}
为我工作。谢谢! –