If my understanding is correct, then camel routes do not have a ‘complete’ state therefore it doesn’t make sense to say something like
camelContext.addRoute(route1);
camelContext.start();
while(0)
{
ifComplete(route1)
break;
}
camelContext.stop();
and in most examples I’ve seen it is written something like
camelContext.start();
Thread.sleep(someDeterminedAmountOfTime);
camelContext.stop();
I have a data transformation of somewhere in the ballpark of 25Gb
and I have no idea how long this will take. So what would be best practice here? (I was thinking maybe grossly overestimate the time to complete, and then try and fine tune from there using the logging messages from my route)
the route:
CsvDataFormat csv = new CsvDataFormat();
from(file:/path/to/file/?fileName=fileName&noop=true)
.split(body().tokenize("/n")).streaming()
.unmarshall(csv)
.process(new CsvParserProcess())
.marshal(csv)
.to(file:/path/to/new/file/?fileName=out.csv).log("finished").end();
3
Answers
So you just want to wait until execution of the route is complete, right? One way is to use one of
org.apache.camel.main.MainSupport
implementations, for exampleorg.apache.camel.spring.javaconfig.Main
. The code could be something like:camel spring boot has a property named camel.springboot.duration-max-messages that may help.
As mentioned in the earlier answer
org.apache.camel.main.Main
class is what you are looking for. Therun()
method in this class would start another thread and will be active unless you manually terminate its execution. For standalone integrations that should run for longer durations, have a look at this reference in the apache camel website long-running-camel-integrationsIn short, you would end up doing something like this.
You can have a look at working example here – apache-camel-kafka