首页 文章

从Spring注释配置初始化camel

提问于
浏览
7

我正在努力学习Spring并了解它是如何工作的 . 我已经按照一些教程设置了Spring和Camel,并使用默认设置 .

我现在正尝试尽可能多地将配置XML文件转换为Java类 . 到目前为止,我已经成功地在Java类中创建了camel-routes(扩展了SpringRouteBuilder并实现了configure()),以及我的spring-configuration文件中的所有bean(Bean-> Function with @Bean) . 我唯一缺少的部分是camelContext定义(?),它启动了我的驼峰路线(我认为......):

<camel:camelContext id="camel5">
    <camel:package>net.krg.kneip.routing</camel:package>
</camel:camelContext>

这个等效的非XML会是什么?

不确定它是否会有所帮助,但到目前为止这是我的AppConfig类:http://pastebin.com/vsRAbpK1

谢谢!

SOLUTION:

@Bean
public CamelContext camel() throws Exception{   
  CamelContext camelContext = new DefaultCamelContext();    
  camelContext.addRoutes(new net.krg.kneip.routing.Routes());
  camelContext.start();
  return camelContext;      
}

1 回答

  • 6
    CamelContext context = new DefaultCamelContext();
    

    我想这就是你要找的东西 .

    Read more here

相关问题