-1

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. ?

ssD
  • 339
  • 2
  • 9
  • 22

1 Answers1

0

See this FAQ: http://camel.apache.org/running-camel-standalone.html and this http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html. You need to startup Spring/Camel and keep the JVM running and allow the route to run and download from the FTP server. This happens automatic, you do not call the route to make it run when its consuming from a FTP endpoint.

I suggest to study Camel some more how it works etc to better understand it. There is for example a FTP example and others at: https://github.com/apache/camel/tree/master/examples#examples

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65
  • Hi Claus, I want to programmatically do it because i want to control the timing of downloads and one of my multiple machines only do this downloads. So i am looking to invoke the route in my camel context – ssD Jun 13 '17 at 21:42