apache camel 是轻量级esb框架。如下是它的架构图:
它有几个比较重要的概念就是:
1.endpoint,所谓的endpoint,就是一种可以接收或发送数据的组件。可以支持多种协议,如jms,http,file等。
2.processor,它是用来处理具体业务逻辑的组件。
3.route,用来路由,指示数据从哪里来到哪里去,中间用哪个processor处理。
而processor之间用exchange对象来传送数据,有点像jms,通俗一点就像上学时传的小纸条,
所以:exchange对象就是processor,endpoint所有camel组件之间传送数据的小纸条:)。
那么camel主要用在哪个领域或哪个场景呢?以下是apache camel 官网上的说明:
Camel empowers you to define routing and mediation rules in a variety of domain-specific languages, including a Java-based Fluent API, Spring or Blueprint XML Configuration files, and a Scala DSL. This means you get smart completion of routing rules in your IDE, whether in a Java, Scala or XML editor.
Apache Camel uses URIs to work directly with any kind of Transport or messaging model such as HTTP, ActiveMQ, JMS, JBI, SCA, MINA or CXF, as well as pluggable Components and Data Format options. Apache Camel is a small library with minimal dependencies for easy embedding in any Java application. Apache Camel lets you work with the same API regardless which kind of Transport is used - so learn the API once and you can interact with all the Components provided out-of-box.
Apache Camel provides support for Bean Binding and seamless integration with popular frameworks such as CDI, Spring, Blueprint and Guice. Camel also has extensive support for unit testing your routes.
还有stackoverflow上的讨论:
http://stackoverflow.com/questions/8845186/what-exactly-is-apache-camel
按我的理解,camel就是企业信息集成框架,它提供了很多简单好用而又强大的组件,用户可以根据场景来选择不同的EIP(企业集成模式)来实现自己的需求,以响应快速变化的业务。可以把它当成企业信息总线(ESB)的轻量级实现。