Reputation: 647
I try to create a route, that can access http url with csv file and simply print the content of it. 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!
Upvotes: 3
Views: 3551
Reputation: 55750
The timer will keep calling every 5th seconds. If you only want to call the timer one time, you can set repeatCount=1
: http://camel.apache.org/timer
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?
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
Upvotes: 2