Apache Camel添加动态路由
2015-10-08 09:52
881 查看
方法一:
定义RoutBuilder的方法
方法二:
定义RouteDefinition的方法
定义RoutBuilder的方法
public static void fun1(String[] args) throws Exception { ModelCamelContext context = new DefaultCamelContext(); context.start(); RouteBuilder route = new RouteBuilder() { public void configure() throws Exception { from("timer://aa?repeatCount=1").process(new Processor(){ public void process(Exchange exchange) throws Exception { System.out.println(exchange.getProperties()); System.out.println(exchange.getIn().getHeaders()); System.out.println("+++++++++++++"); } }); } }; context.addRoutes(route); TimeUnit.SECONDS.sleep(20); context.stop(); }
方法二:
定义RouteDefinition的方法
public static void fun2(String[] args) throws Exception { ModelCamelContext context = new DefaultCamelContext(); context.start(); RouteDefinition rd = new RouteDefinition(); rd.id("dynaRoute001").from("timer://aa?repeatCount=1").process(new Processor(){ public void process(Exchange exchange) throws Exception { System.out.println(exchange.getProperties()); System.out.println(exchange.getIn().getHeaders()); System.out.println("+++++++++++++"); } }); context.addRouteDefinition(rd); TimeUnit.SECONDS.sleep(20); context.stop(); }
相关文章推荐
- centos6.6环境下配置PHP,apache与m…
- apache2.2以后,每次升级系统,比如Yosemite 或者 EL Capitan版本 apache都要重新配置
- 基于apache.tools.zip压缩文件(夹)
- 阿里云云服务器CentOS上安装Apache
- Apache POI 之 初学实战篇 (二) --- 创建Sheet
- Apache POI 之 初学实战篇 (一) --- 创建excel文件
- Apache POI使用详解
- Mac apache配置问题解决
- c apache2模块开发--根据自定义业务逻辑实现文件下载
- XAMPP Apache启动失败
- springmvc 集成apache cxf 开发webservice 示例
- web服务器缓存(二)
- NAT负载均衡方式,apache如何在日志中记录客户端IP
- Apache Drill学习
- Apache Drill学习
- Apache Drill学习
- Apache Drill学习
- Apache Drill学习
- Apache Drill学习
- Apache Drill学习