![](/img/trans.png)
[英]How to load property file values dynamically in apache camel + spring
[英]How to use Apache Camel to load just a single file?
Apache Camel对FTP和“文件”等各种协议都有很好的支持,我想使用它只是加载单个文件并进行一些转换。
我理解了如何像示例中一样使用RouteBuilder和CamelContext.start()来做到这一点,但我不想在无尽循环中使用后台守护程序,也不需要复杂的路由。
我该怎么做:
String body = new DefaultCamelContext().justRunOnce(
from("ftp://ftp.example.com/data/foo.txt")
.validate(body().regex("My Data.*"))
.getBody());
我确实读过一些有关如何使用“ controlbus?action = stop”或“ timer?repeat = 1”或类似的方法停止路由的答案,但是那些仍然将Camel作为新线程启动,然后使用一些技巧将其停止。 我不是在寻找某种可以通过某种方式来管理它的复杂解决方案,而是想知道Camel是否能够像在上面的示例中那样用在薄的10衬套中。
您可以使用pollEnricht功能,请参阅http://camel.apache.org/content-enricher.html :
例如,您还可以使用ftp端点而不是文件端点:
<route>
<from uri="direct:start"/>
<pollEnrich>
<constant>file:inbox?fileName=data.txt</constant>
</pollEnrich>
<to uri="direct:result"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.