I have a camel context defined in the springs beans.xml.
Now i want to programatically invoke the route in camel context. How do i Do that. I want to programatically do this because I want one of my multiple nodes to run this download. I dont want all the nodes with this camel to run the download. I am planning to run this as a job or use zookeeper but dont want to change the way we have written the camel route.
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<!-- Camel context which holds the route definitions -->
<camelContext id="camelpriceroutebean" errorHandlerRef="errorHandler"
xmlns="http://camel.apache.org/schema/spring">
<route id="download-from-ftp" autoStartup="true" startupOrder="1">
Now i have tried using following code
ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/springbean.xml");
CamelContext camel = (CamelContext) context.getBean("camelpriceroutebean");
List<Route> routes = camel.getRoutes();
But the springbean.xml is throwing expcetion . Is there another way to handle this. ?