[英]How can I read csv file using apache camel only once from http?
I try to create a route, that can access http url with csv file and simply print the content of it. 我尝试创建一个路径,可以使用csv文件访问http url并简单地打印它的内容。 Unfortunately the file is being read continuously. 不幸的是,文件正在不断读取。
Here is my code: 这是我的代码:
context.addRoutes(new RouteBuilder() {
public void configure() {
from("timer://start?delay=5000")
.to("http4://127.0.0.1:18080/data.csv")
.unmarshal().csv()
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
String list = exchange.getIn().getBody(String.class);
log.info(list);
//Here I would like to stop the route when file reading is finished
}
});
});
Thanks! 谢谢!
The timer will keep calling every 5th seconds. 计时器将每隔5秒钟保持一次通话。 If you only want to call the timer one time, you can set repeatCount=1
: http://camel.apache.org/timer 如果您只想调用一次计时器,可以设置repeatCount=1
: http : repeatCount=1
But you may need to consider do you want to only let it run once. 但您可能需要考虑是否只让它运行一次。 What if you need to call that HTTP url again sometime later? 如果您需要稍后再次调用该HTTP URL,该怎么办?
And also as Frank commented there is a way to stop a route from a route: http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html 而且正如弗兰克评论的那样,有一种方法可以阻止路线的路线: http : //camel.apache.org/how-can-i-stop-a-route-from-a-route.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.