I am using it because camel looks to have a strange behavior. I would like to execute code at the end of (spring/camel) context loading and if the code execution is OK then start an other route. ( First I download referential data and load it ) ( Secondly start route which process file and enrich it with data load previously).
For that I do : // This route is not started at the begining from("file://C:/Temp/camel/?noop=true") .routeId("ROUTE_1") .id("ROUTE_1") .autoStartup(false) .log("file => ${file:name}") .end(); // This route is executed once and call a processor which load data and start route 1 from("timer://runOnce?repeatCount=1&delay=1000") .autoStartup(true) .process(new MyProcessor()) .end(); And MyProcessor : public class MyProcessor implements Processor { static Logger LOG = LoggerFactory.getLogger(MyProcessor.class); public void process(Exchange exchange) throws Exception { LOG.info("start MyProcessor"); CamelContext camelContext = exchange.getContext(); Route route = camelContext.getRoute("ROUTE_1"); boolean isStarted = ((org.apache.camel.support.ServiceSupport)route).isStarted(); if(isStarted) { camelContext.suspendRoute("ROUTE_1", 1,TimeUnit.HOURS); } LOG.info("resume route 1 "); camelContext.resumeRoute("ROUTE_1"); LOG.info("end MyProcessor"); } } IF I do a test if route is started then the resume (start) really start : [1) thread #0 - timer://runOnce] MyProcessor INFO start MyProcessor [1) thread #0 - timer://runOnce] MyProcessor INFO resume route 1 [1) thread #0 - timer://runOnce] SpringCamelContext INFO Route: ROUTE_1 started and consuming from: Endpoint[file://C:/Temp/camel/?noop=true] [1) thread #0 - timer://runOnce] MyProcessor INFO end MyProcessor [ead #2 - file://C:/Temp/camel/] ROUTE_1 INFO file => AED_20130208122307_00006 - Copy.recycle [ead #2 - file://C:/Temp/camel/] ROUTE_1 INFO file => AED_20130208122307_00006.recycle [ead #2 - file://C:/Temp/camel/] ROUTE_1 INFO file => AS_20130508122307_73dee092-7.csv But If I suspend in all case : public class MyProcessor implements Processor { [...] Route route = camelContext.getRoute("ROUTE_1"); camelContext.suspendRoute("ROUTE_1", 1,TimeUnit.HOURS); LOG.info("resume route 1 "); camelContext.resumeRoute("ROUTE_1"); [...] Then the route is not really started : [1) thread #0 - timer://runOnce] MyProcessor INFO resume route 1 [1) thread #0 - timer://runOnce] SpringCamelContext INFO Route: ROUTE_1 resumed and consuming from: Endpoint[file://C:/Temp/camel/?noop=true] [1) thread #0 - timer://runOnce] MyProcessor INFO end MyProcessor <nothing after > I am using camel 2.11 / JRE 1.7 Bye Jeff 2013/4/25 Jean Francois LE BESCONT <jflebesc...@gmail.com> > > Hey Folks ! > > Just a little post to say that it sound tricky to detect if a route is > started or not, the only way I have found is to do : > > Route route = camelContext.getRoute(...); > boolean isRouteStarted = > ((org.apache.camel.support.ServiceSupport)route).isStarted(); > > Bye > > Jeff > >