Apache Camel 中camel配置文件引入其他xml文件介绍--将camel配置文件拆分后并引用
2016-02-19 16:10
691 查看
1、rest
可以在新文件中用<restContext/>标签
例如:需要导入的文件myCoolRests.xml,内容为
在camel的配置文件中用spring导入,如:<import resource="myCoolRests.xml" />
然后在<camelContext/>标签中通过<restContextRef>标签引入,标签中参数ref等于<restContext/>的id值。
例如:
注意:<restContextRef>标签可以在<camelContext>标签中重复使用。
2、route
可以在新文件中使用<routeContext>标签
例如:需要导入的文件myCoolRoutes.xml,内容为
在camel的配置文件中用spring导入,如:<import resource="myCoolRoutes.xml" />
然后在<camelContext/>标签中通过<routeContextRef>标签引入,标签中参数ref等于<restContext/>的id值。
例如:
注意:同<restContextRef>标签一样<routeContextRef>标签可以在<camelContext>标签中重复使用。
可以在新文件中用<restContext/>标签
例如:需要导入的文件myCoolRests.xml,内容为
<restContext id="myCoolRest" xmlns="http://camel.apache.org/schema/spring"> <rest uri="/say/hello"> <get> <to uri="direct:hello"/> </get> </rest> </restContext>
在camel的配置文件中用spring导入,如:<import resource="myCoolRests.xml" />
然后在<camelContext/>标签中通过<restContextRef>标签引入,标签中参数ref等于<restContext/>的id值。
例如:
<camelContext xmlns="http://camel.apache.org/schema/spring"> <restContextRef ref="myCoolRest"/> <rest uri="/say/bye"> <get consumes="application/json"> <to uri="direct:bye"/> </get> <post> <to uri="mock:update"/> </post> </rest> <route> <from uri="direct:hello"/> <transform> <constant>Hello World</constant> </transform> </route> <route> <from uri="direct:bye"/> <transform> <constant>Bye World</constant> </transform> </route> </camelContext>
注意:<restContextRef>标签可以在<camelContext>标签中重复使用。
2、route
可以在新文件中使用<routeContext>标签
例如:需要导入的文件myCoolRoutes.xml,内容为
<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.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd "> <!-- this is an included XML file where we only the the routeContext --> <routeContext id="myCoolRoutes" xmlns="http://camel.apache.org/schema/spring"> <!-- we can have a route --> <route id="cool"> <from uri="direct:start"/> <to uri="mock:result"/> </route> <!-- and another route, you can have as many your like --> <route id="bar"> <from uri="direct:bar"/> <to uri="mock:bar"/> </route> </routeContext> </beans>
在camel的配置文件中用spring导入,如:<import resource="myCoolRoutes.xml" />
然后在<camelContext/>标签中通过<routeContextRef>标签引入,标签中参数ref等于<restContext/>的id值。
例如:
<!-- import the routes from another XML file --> <import resource="myCoolRoutes.xml"/> <camelContext xmlns="http://camel.apache.org/schema/spring"> <!-- refer to a given route to be used --> <routeContextRef ref="myCoolRoutes"/> <!-- we can of course still use routes inside camelContext --> <route id="inside"> <from uri="direct:inside"/> <to uri="mock:inside"/> </route> </camelContext>
注意:同<restContextRef>标签一样<routeContextRef>标签可以在<camelContext>标签中重复使用。
相关文章推荐
- 分享一个自己在用的apache mina的解码器decoder源码
- Apache benchmark测试工具
- apache工作模式:prefork和worker
- mybatis的org.apache.ibatis.builder.IncompleteElementException问题
- apache支持php
- apache 局域网访问
- commons.apache
- apache三种工作模式
- apache的并发数量设置
- Apache2.2 提示the requested operation has failed并无法启动
- PHP7与Apache2.4关联配置
- linux 下 Apache 安装
- 解决ubuntu中apache2的url大小写敏感问题。
- 基于Linux安装Apache环境搭建过程及报错解决方案
- 《PHPMySQL和Apache编程导学》
- Apache-Maven学习(转)
- Apache Rewrite的主要功能
- linux下安装apache+php详解
- Apache 2.4. 源码编译安装详解
- java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlOptions