从Spring注释配置初始化camel
我正在努力学习Spring并了解它是如何工作的。 我已经按照一些教程设置了Spring和Camel,并使用默认设置。
我现在正尝试尽可能多地将我的配置XML文件转换为Java类。 到目前为止,我已经成功地在Java类中创建了camel-routes(扩展了SpringRouteBuilder并实现了configure()),以及我的spring-configuration文件中的所有bean(Bean-> Function with @Bean)。 我唯一缺少的部分是camelContext定义(?),它启动了我的驼峰路线(我认为……):
net.krg.kneip.routing
这个等效的非XML会是什么?
不确定它是否会有所帮助,但到目前为止我的AppConfig类是: http : //pastebin.com/vsRAbpK1
谢谢!
解:
@Bean public CamelContext camel() throws Exception{ CamelContext camelContext = new DefaultCamelContext(); camelContext.addRoutes(new net.krg.kneip.routing.Routes()); camelContext.start(); return camelContext; }
CamelContext context = new DefaultCamelContext();
我想这就是你要找的东西。
在这里阅读更多