Apache Camel是Apache基金会下的一个开源项目,它是一个基于规则路由和处理的引擎,提供企业集成模式的Java对象的实现,通过应用程序接口或称为陈述式的Java领域特定语言(DSL)来配置路由和处理的规则。其核心的思想就是从一个from源头得到数据,通过processor处理,再发到一个to目的的.
这个from和to可以是我们在项目集成中经常碰到的类型:一个FTP文件夹中的文件,一个MQ的queue,一个HTTP request/response,一个webservice等等.
Camel可以很容易集成到standalone的应用,在容器中运行的Web应用,以及和Spring一起集成.
<route>
<from uri="jms:queue:order"/>
<pipeline>
<bean ref="validateOrder"/>
<bean ref="registerOrder"/>
<bean ref="sendConfirmEmail"/>
</pipeline>
</route>
Pipeline is default
In the route above we specify pipeline but it can be omitted as its default, so you can write the route as:
<route>
<from uri="jms:queue:order"/>
<bean ref="validateOrder"/>
<bean ref="registerOrder"/>
<bean ref="sendConfirmEmail"/>
</route>
An example where the pipeline needs to be used, is when using a multicast and "one" of the endpoints to send to (as a logical group) is a pipeline of other endpoints. For example.
<route>
<from uri="jms:queue:order"/>
<multicast>
<to uri="log:org.company.log.Category"/>
<pipeline>
<bean ref="validateOrder"/>
<bean ref="registerOrder"/>
<bean ref="sendConfirmEmail"/>
</pipeline>
</multicast>
</route>
The above sends the order (from jms:queue:order) to two locations at the same time,our log component, and to the "pipeline" of beans which goes one to the other.
<route>
<from uri="jms:queue:order"/>
<multicast>
<to uri="log:org.company.log.Category"/>
<bean ref="validateOrder"/>
<bean ref="registerOrder"/>
<bean ref="sendConfirmEmail"/>
</multicast>
</route>
you would see that multicast would not "flow" the message from one bean to the next, but rather send the order to all 4 endpoints (1x log, 3x bean) in parallel, which is not (for this example) what we want. We need the message to flow to the validateOrder, then to the registerOrder, then the sendConfirmEmail so adding the pipeline, provides this facility.
<route>
<from uri="jms:queue:order"/>
<to uri="bean:validateOrder"/>
<to uri="mina:tcp://mainframeip:4444?textline=true"/>
<to uri="bean:sendConfirmEmail"/>
</route>
What we now have in the route is a to type that can be used as a direct replacement for the bean type.
<route>
<from uri="jms:queue:order"/>
<bean ref="validateOrder"/>
<to uri="mina:tcp://mainframeip:4444?textline=true"/>
<bean ref="sendConfirmEmail"/>
</route>
待续......
分享到:
相关推荐
ApacheCamel-JDBC Apache Camel JDBC组件 代码样例Demo
Apache Camel 开发使用指南中文版
ApacheCamel-FTP ApacheCamel-FTP Apache Camel FTP组件 Demo 样例
该文档来自阿帕奇2015中国路演。姜宁发表了题为“我和Apache Camel这些年/Years of Apache Camel and I”的主题演讲,欢迎下载!
简化软件集成:一个ApacheCamel教程在本教程中,您将了解集成大型软件的一些最大挑战,以及ApacheCamel如何轻松解决这些难题。在您的软件工程中,您可能至少做了一次以下操作:1.确定应启动数据发送的业务逻辑片段。...
01-ApacheCamel-HelloWorld Apache Camel Http helloworld Demo
05-ApacheCamel-CXF-WebService Apache Camel 集成 CXF组件,包含服务端、测试客户端
camel-idea-plugin, Apache camel IntelliJ IDEA 插件 Apache camel IDEA插件 IntelliJ IDEA的插件,为代码编辑器提供一组 Apache camel 相关的功能。插件包括:Java,XML,属性或者yaml文件中驼峰终结点的代码完成...
An advanced guide to Enterprise Integration using Apache Camel About This Book Integrate your applications with Apache Camel and enhance efficiency and scalability Master all the EIPs supported by ...
骆驼开发指南,企业集成,路由表达式和判断,camel高级编程,api组件框架,耗时半年翻译成果,全部为markdown文档!!!
camel direct http jdbc mybatis 等等组件 骆驼 camel部分源码分析
apache camel for windows
Apache Camel 框架实现的JMS路由。有图解,很详细。
ApacheCamel-JMS-ActiveMQ Apache Camel JMS ActiveMQ 使用样例 1.从本地读取信息推送到MQ中 2.从MQ中读取信息保存到本地
09-ApacheCamel-Timer Apache Camel Timer组件 定时器 代码Demo
此文档主要针对以下四个问题进行详细分析以及解答。 第一:我们要解决的企业应用集成问题。 第二:为什么使用Camel; 第三:Camel可以做什么? 第四:Camel的核心要素。
Apache Camel Demo Apache Camel Blog: 之前不小心将一些无用的配置文件上传了,请自行清除 该项目中包含 Apache Camel - FTP组件 Apache Camel - CXF组件(Code First and WSDL File First) Apache Camel - JMS/...