`
maosheng
  • 浏览: 560260 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Apache Camel 点滴

 
阅读更多
    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>

待续......



分享到:
评论

相关推荐

    Apache Camel中文开发使用指南.zip

    Apache Camel 是一个强大的开源框架,专门用于构建企业级应用程序中的集成解决方案。它提供了一种声明式的方式,使得开发者可以轻松地定义数据路由和处理规则,从而实现系统间的通信。这个"Apache Camel 开发使用...

    ApacheCamel-JDBC

    Apache Camel 是一个流行的开源集成框架,它允许开发者以声明式的方式定义路由和转换数据,使得在不同的软件组件之间实现通信变得更加简单。JDBC(Java Database Connectivity)是Java平台中的一个标准API,用于与...

    姜宁-我和Apache Camel这些年/Years of Apache Camel and I

    Apache Camel是Apache软件基金会下的一个开源集成框架,它实现了企业集成模式(Enterprise Integration Patterns,EIP),旨在简化在企业中的应用程序、系统和服务之间的集成工作。Camel支持多种传输协议,如HTTP、...

    Apache Camel Developer's Cookbook

    Apache Camel是一种开源的集成框架,其目的在于简化企业应用集成和规则流程的开发。它基于企业集成模式(Enterprise Integration Patterns),使得不同系统之间的消息传递和数据交换变得更加容易。Apache Camel支持...

    Apache Camel 框架之---JMS路由.docx

    Apache Camel 框架之 JMS 路由 Apache Camel 框架实现的 JMS 路由是指使用 Apache Camel 框架来实现 Java 消息服务(JMS)的路由。JMS 是一个 Java API,用于在 Java 应用程序之间进行消息传递。Apache Camel 框架...

    Apache Camel 开发指南.rar

    Apache Camel 是一个强大的开源企业级集成框架,它简化了在Java应用程序之间建立复杂的消息传递流程。这个"Apache Camel 开发指南"压缩包包含了丰富的资源,帮助开发者深入理解Camel的各个方面,包括路由表达式、...

    apache camel 集成组件 教程

    ### Apache Camel 集成组件教程 #### 一、Apache Camel 概述 Apache Camel 是一个强大的开源消息中间件框架,旨在简化企业级应用中的消息处理逻辑。它提供了一种简单而灵活的方式来定义复杂的路由和数据转换规则。...

    ApacheCamel-FTP

    Apache Camel 是一个流行的开源集成框架,它允许开发者在不同的系统、协议和服务之间建立灵活的数据通信。FTP(File Transfer Protocol)是互联网上广泛使用的文件传输协议,用于上传、下载和管理远程服务器上的文件...

    Java_Apache Camel Spring Boot示例.zip

    Java_Apache Camel Spring Boot示例是一个综合性的项目,展示了如何在Spring Boot应用程序中集成Apache Camel框架。Apache Camel是一个流行的开源框架,它简化了企业级集成(EIP,Enterprise Integration Patterns)...

    05-ApacheCamel-CXF-WebService

    Apache Camel 是一个强大的开源企业集成库,它提供了一种模型化的路由和消息转换方式,使得开发者可以轻松地在各种系统间构建复杂的集成解决方案。CXF 是一个流行的开放源代码服务框架,它支持多种Web服务标准,如...

    apache-camel-3.7.0_数据同步_

    Apache Camel 是一个强大的开源框架,专门用于构建企业级集成解决方案。在标题“apache-camel-3.7.0_数据同步_”中提到的“数据同步”,是指利用Apache Camel实现不同系统、数据库或应用程序间的数据交换和一致性...

    Apache Camel 源码分析.rar

    Apache Camel 是一个强大的开源企业集成库,它提供了一种声明式的方式来定义路由和转换数据,使得构建复杂的分布式系统变得更加简单。Camel 使用一种名为“DSL”(Domain Specific Language)的语法规则,允许开发者...

    简化软件集成:一个ApacheCamel教程

    简化软件集成:一个ApacheCamel教程在本教程中,您将了解集成大型软件的一些最大挑战,以及ApacheCamel如何轻松解决这些难题。在您的软件工程中,您可能至少做了一次以下操作:1.确定应启动数据发送的业务逻辑片段。...

    01-ApacheCamel-HelloWorld

    Apache Camel 是一个强大的开源集成框架,它允许开发者在各种组件之间路由、转换和处理消息,以构建企业级的集成解决方案。在这个"01-ApacheCamel-HelloWorld"示例中,我们将深入理解如何使用 Camel 实现一个简单的 ...

    apache camel

    Apache Camel 是一个强大的开源集成框架,它允许开发者在各种企业应用程序之间建立灵活、可重用的数据路由和集成解决方案。这个框架的核心理念是“统一的消息模型”,它提供了多种组件,支持多种协议和数据格式,...

    camel-idea-plugin, Apache camel IntelliJ IDEA 插件.zip

    camel-idea-plugin, Apache camel IntelliJ IDEA 插件 Apache camel IDEA插件 IntelliJ IDEA的插件,为代码编辑器提供一组 Apache camel 相关的功能。插件包括:Java,XML,属性或者yaml文件中驼峰终结点的代码完成...

    ApacheCamel快速入门(上)

    在这个专题中,我们介绍了相当数量技术组件:Flume、Kafka、ActiveMQ、Rabbitmq、Zookeeper、Thrift、Netty、DUBBO等等,还包括本文要进行介绍的ApacheCamel。有的技术组件讲得比较深入,有的技术组件则是点到为止。...

Global site tag (gtag.js) - Google Analytics