//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);
}
}
}
2条答案
按热度按时间kuuvgm7e1#
您也可以使用计划路由策略http://camel.apache.org/scheduledroutepolicy.html
o75abkj42#
您可以使用计时器/石英开始计时,然后使用content enricher或polling consumer