我在spring beans.xml中定义了骆驼上下文。在Beans.xml中定义的CamelContext。我如何以编程方式实例化camelContext路由
现在我想以编程方式在骆驼上下文中调用路由。我怎么做。我想以编程方式执行此操作,因为我想让我的多个节点之一运行此下载。我不想让这个骆驼的所有节点都运行下载。我打算将这作为一项工作或使用动物园管理员,但不想改变我们编写骆驼路线的方式。
<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">
现在我已经用下面的代码
ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/springbean.xml");
CamelContext camel = (CamelContext) context.getBean("camelpriceroutebean");
List<Route> routes = camel.getRoutes();
试过但springbean.xml抛出expcetion。有没有另一种方法来处理这个问题。 ?
嗨克劳斯,我想以编程方式做到这一点,因为我想控制下载的和我的多台机器的一个唯一做到这一点的下载时间。所以我正在寻找在我的骆驼环境中调用路线 – ssD