<p><span>在1.4中介绍了</span>Camel的整体架构,以及Camel中的一些概念.</p> <p><strong>架构图</strong></p> <p><img src="file:///C|/Users/vastdream/AppData/Roaming/Zoundry/Zoundry%20Raven/My%20Profile/resourcestore/zrclip_001p6bc60906.png" height="352" width="787"/></p> <p>关于各个概念不在此详述.</p> <p><strong>Camel的主要流程:</strong></p> <p>1:创建CamelContext</p> <blockquote style="MARGIN-RIGHT: 0px" dir="ltr"> <p><em>CamelContext context = new DefaultCamelContext();</em></p> </blockquote> <p>2.添加Component</p> <blockquote> <p><em><em>context.addComponent("direct", new DirectComponent());</em></em></p> <p><em style="COLOR: #ff0000">注:context如果找不到对应的component会自动去META-INF\services\org\apache\camel\component查找对应的component并自动加载.所以常用组件可省略.</em></p> </blockquote> <p><span style="COLOR: #000000">3.创建Endpoint</span></p> <blockquote> <p><span style="COLOR: #000000"><em><em>component.createEndpoint("direct:start");</em></em></span></p> </blockquote> <p><span style="COLOR: #000000">4.定义路由</span></p> <p><em>RouteBuilder builder = new RouteBuilder() { <br/> @Override <br/> public void configure() throws Exception { <br/> from("direct:start") <br/> .log("${body}") <br/> .to("mock:end"); <br/> } <br/> };</em></p> <p>5.把路由加入context中</p> <p><em>builder.addRoutesToCamelContext(context);</em></p> <p>6.启动context:</p> <p>context.start();</p> <p><span style="COLOR: #ff0000">注:前面3步都可以省略,一般情况下只需要4,5,6.其余步骤context启动时会自动创建.</span></p>
来源:oschina
链接:https://my.oschina.net/u/574870/blog/134971