2013-08-06 41 views
1

我有我的路由的自动启动设置为false:如何通过Spring XML手动启动骆驼路线?

<route id="myRoute" autoStartup="false"> 

一切我可以在网上找到关于如何启动之后即在Java启动它,并说打电话startRoute("myRoute");在camelContext ..但我在Spring XML的路由中找不到有关如何调用它的任何信息。

这里是我的设置:

<route id="myRoute" autoStartup="false"> 
    <from uri="ftp://remote/dir" /> 
    <to uri="file:///local/dir" /> 
</route> 
<route id="kickOff"> 
    <from uri="timer://runOnce?repeatCount=1&amp;delay=30000" /> 
    <!-- START myRoute HERE --> 
    <to uri="bean:postProcessor?method=postProcess" /> 
</route> 

我的目标是让FTP得到了FTP的所有文件一次,然后停止这条路线。目前它将无限期地继续轮询FTP。我尝试添加一个限制为1的org.apache.camel.impl.LimitedPollingConsumerPollStrategy,但这似乎没有改变任何内容。

回答

6

参见控制总线EIP /组件,你可以开始路线:

的代码应该是一样:

<route id="kickOff"> 
    <from uri="timer://runOnce?repeatCount=1&amp;delay=30000" /> 
    <to uri="controlbus:route?routeId=myRoute&action=start" /> 
    <to uri="bean:postProcessor?method=postProcess" /> 
</route>