I saw the code fo DefaultCamelContext and I think I can use the method
public synchronized void addRouteDefinitions(Collection<RouteDefinition>
routeDefinitions) throws Exception {
for (RouteDefinition routeDefinition : routeDefinitions) {
removeRouteDefinition(routeDefinition);
}
this.routeDefinitions.addAll(routeDefinitions);
if (shouldStartRoutes()) {
startRouteDefinitions(routeDefinitions);
}
}
My RouteBuilder will be a spring-groovy file , once I change the file
spring will reload . I will use a servlet to update the camel context by
calling addRouteDefinitions to which I will pass
SpringApplicationContext.getBean("myrouteBuilder). getRouteCollection().
what happens to the processor My routebuilder is this
public class NearBatchFilesRouteBuilder extends RouteBuilder {
public void configure() {
from("file:///u01/oracle/artms-near/NEW?delay=60000&move=../PROCESSED")
.convertBodyTo(String.class)
.aggregate(constant(true)).completionSize(10).completionTimeout(10000L).groupExchanges()
.process(new
FileProcessor()).to("jms:queue:gov.hhs.newBatch.queue");
}
public static class FileProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
List<BatchFile> batchFiles=
Lists.newArrayList(Iterables.transform(exchange.getProperty(Exchange.GROUPED_EXCHANGE,
ArrayList.class), new Function<Exchange, BatchFile>() {
@Override
public BatchFile apply(Exchange input) {
BatchFile batchFile= new BatchFile();
String
filename=(String)input.getIn().getHeader(Exchange.FILE_NAME);
batchFile.setFileName(FilenameUtils.getName(filename));
batchFile.setFiledata(input.getIn().getBody(String.class).getBytes());
batchFile.setFileType(StringUtils.contains(filename,
"tblACFReportInfo")? BatchFile.FileType.AUDIT:BatchFile.FileType.FINDING);
return batchFile;
}
}));
Batch
batch=((BatchService)SpringApplicationContext.getBean("batchService")).createNewBatch(batchFiles);
exchange.getIn().setBody(batch.getSysBatchId());
}
}
}
above class is a groovy file and I load this using <lang:groovy....../>
at runtime I change the FileProcessor code and spring will reload
this class, now I will access aservlet in the servlet I call
camelContext.addRouteDefinitions(SpringApplicationContext.getBean("myrouteBuilder).
getRouteCollection())
this will reload the rootdefinitions but what happens to processor ? are
they also get updated ?
--
View this message in context:
http://camel.465427.n5.nabble.com/reload-routebuilder-at-runtime-tp4521292p4532138.html
Sent from the Camel - Users mailing list archive at Nabble.com.