Camel在集成空间中引入了一些新颖的想法,作者创建Camel不是使用现有的框架。
我们将在整本书中探索丰富的Camel特性集,这些是Camel背后的主要思想:

Routing and mediation engine
路由和中介引擎
Enterprise integration patterns (EIPs)
企业集成模式(EIP)
Domain-specific language (DSL)
领域特定语言(DSL)
Extensive component library
扩展组件库
Payload-agnostic router
动态负载路由
Modular and pluggable architecture
模块化&可插拔架构
POJO model
POJO模型
Easy configuration
容易配置
Automatic type converters
自动类型转换
Lightweight core
轻量级核心
Test kit
测试套件
Vibrant community
有活力的社区

  1. Lets dive into the details of each of these features.

让我们深入了解每个功能的细节。

  1. ### ROUTING AND MEDIATION ENGINE
  2. The core feature of Camel is its routing and mediation engine. A routing engine will
  3. selectively move a message around, based on the routes configuration. In Camels
  4. case, routes are configured with a combination of enterprise integration patterns and
  5. a domain-specific language, both of which well describe next.

路由和中介引擎
Camel的核心特性是其路由和中介引擎。路由引擎将根据路由的配置有选择地移动消息。
路由(route)是由企业集成模式和领域的语言配置,下面我们将描述这两种语言。

  1. ### ENTERPRISE INTEGRATION PATTERNS (EIPS)
  2. Although integration problems are diverse, Gregor Hohpe and Bobby Woolf noticed
  3. that many problems and their solutions are quite similar. They cataloged them
  4. in their book Enterprise Integration Patterns, a must-read for any integration professional (http://www.enterpriseintegrationpatterns.com). If you haven’t read it, we
  5. encourage you to do so. At the very least, it will help you understand Camel concepts
  6. faster and easier.

企业集成模式(EIP)
尽管集成问题是多样的,2个帅哥注意到了许多问题和它们的解决方法是非常相似的。他们把它们编了目录
在他们的书《企业集成模式》中,任何集成专业人士都必须阅读(http://www.enterpriseintegrationpatterns.com). 如果你没读过,我们
鼓励你这样做。至少,它会帮助你更快更容易理解Camel的概念

  1. The enterprise integration patterns, or EIPs, are helpful not only because they provide a proven solution for a given problem, but also because they help define and
  2. communicate the problem itself. Patterns have known semantics, which makes communicating problems much easier. The difference between using a pattern language
  3. and describing the problem at hand is similar to using spoken language rather than
  4. sign language. If youve ever visited a foreign country, youve probably experienced
  5. the difference.

企业集成模式(简称eip)之所以有用,不仅因为它们为给定的问题提供了经验证的解决方案,而且还因为它们有助于定义与沟通问题本身。模式具有已知的语义,这使得交流问题更加容易。使用不同语言的模式
描述眼前的问题类似于使用口语,而不是手语。如果你去过国外,你可能有过这种体验。

  1. Camel is heavily based on EIPs. Although EIPs describe integration problems and
  2. solutions and also provide a common vocabulary, the vocabulary isnt formalized.
  3. Camel tries to close this gap by providing a language to describe the integration solutions. Theres almost a one-to-one relationship between the patterns described in
  4. Enterprise Integration Patterns and the Camel DSL.

Camel主要基于eip。尽管eip描述了集成问题和
解决方案还提供了一个能用的词汇表,但是词汇表是没有正式定义的。
Camel试图通过提供描述集成解决方案的语言来弥补这一差距。几乎每种企业集成模式和Camel DSL之间都存在一对一的关系

  1. ### DOMAIN-SPECIFIC LANGUAGE (DSL)
  2. Camels domain-specific language (DSL) is a major contribution to the integration
  3. space. A few other integration frameworks currently feature a DSL (and some allow
  4. you to use XML to describe routing rules), but unlike Camel their DSLs are based on
  5. custom languages. Camel is unique because it offers multiple DSLs in regular programming languages such as Java, Scala, Groovy, and it also allows routing rules to be
  6. specified in XML.

领域特定语言(DSL)
Camel的领域特定语言(DSL)是对企业集成的主要补足。一些其他的集成框架目前以DSL为特征(有些还允许
您需要使用XML来描述路由规则),但与Camel不同,它们的DSL是基于自定义语言。
Camel的独特之处在于它提供了多个用常规编程语言(如Java、Scala、Groovy)编写的dsl,而且它还允许路由规则在XML中指定。

  1. The purpose of the DSL is to allow the developer to focus on the integration problem
  2. rather than on the toolthe programming language. Although Camel is written mostly
  3. in Java, it does support mixing multiple programming languages. Each language has its
  4. own strengths, and you may want to use different languages for different tasks. You have
  5. the freedom to build a solution your own way with as few constraints as possible.

DSL的目的是让开发人员能够专注于集成问题而不是在工具上的编程语言。虽然Camel大部分是写的
在Java中,它确实支持混合多种编程语言。每种语言都有自己的特点
有自己的长处,你可能想用不同的语言来完成不同的任务。你有
以自己的方式构建解决方案的自由,尽可能少的限制。

  1. Here are some examples of the DSL using different languages and staying functionally equivalent:
  2. Java DSL
  3. from("file:data/inbox").to("jms:queue:order");
  4. Spring DSL
  5. <route>
  6. <from uri="file:data/inbox"/>
  7. <to uri="jms:queue:order"/>
  8. </route>
  9. Scala DSL
  10. from "file:data/inbox" -> "jms:queue:order"

以下是一些使用不同语言并保持功能等效的DSL示例:

  1. These examples are real code, and they show how easily you can route files from a
  2. folder to a JMS queue. Because theres a real programming language underneath, you
  3. can use the existing tooling support, such as code completion and compiler error
  4. detection, as illustrated in figure 1.1.

这些示例是真实的代码,它们展示了如何轻松地从将文件夹添加到JMS队列。因为下面有一种真正的编程语言
可以使用现有的工具支持,如代码完成和编译器错误
检测,如图1.1所示。
image.png

  1. ### EXTENSIVE COMPONENT LIBRARY
  2. Camel provides an extensive library of more than 80 components. These components
  3. enable Camel to connect over transports, use APIs, and understand data formats.

扩展组件库

Camel提供了一个包含80多个组件的扩展库。这些组件使Camel能够通过传输连接、使用api和理解数据格式。

### PAYLOAD-AGNOSTIC ROUTER
Camel can route any kind of payload—you aren’t restricted to carrying XML payloads. 
This freedom means that you don’t have to transform your payload into a canonical 
format to facilitate routing.

动态负载路由

Camel可以路由任何类型的有效负载,而不局限于承载XML有效负载。
这种自由意味着您不必将有效负载转换为规范便于路由的格式。

### MODULAR AND PLUGGABLE ARCHITECTURE
Camel has a modular architecture, which allows any component to be loaded into 
Camel, regardless of whether the component ships with Camel, is from a third party, 
or is your own custom creation.

模块化可插拔体系结构

Camel有一个模块化的体系结构,允许将任何组件加载到Camel
无论组件是否与Camel提供的,或来自第三方,或是你自己定制的。

### POJO MODEL
Beans (or POJOs) are considered first-class citizens in Camel, and Camel strives to let 
you use beans anywhere and anytime in your integration projects. This means that in 
many places you can extend Camel’s built-in functionality with your own custom code. 
Chapter 4 has a complete discussion of using beans within Camel.

POJO模型

Bean(或pojo)被认为是Camel的一等公民,Camel努力让它成为一等公民
您可以随时随地在集成项目中使用bean。这意味着
在许多地方,您可以使用自己的自定义代码扩展Camel的内置功能。
第4章完整地讨论了在Camel中使用bean。

### EASY CONFIGURATION
The convention over configuration paradigm is followed whenever possible, which mini￾mizes configuration requirements. In order to configure endpoints directly in routes, 
Camel uses an easy and intuitive URI configuration.
 For example, you could configure a file consumer to scan recursively in a sub￾folder and include only a .txt file, as follows:
from("file:data/inbox?recursive=true&include=*.txt")...

易于配置

只要有可能,就遵循约定优先于配置的范例,从而最小化配置需求。为了直接在路由中配置端点,
Camel使用简单直观的URI配置。
例如,您可以将文件使用者配置为在子文件夹中递归扫描,并且只包含一个.txt文件,如下所示:
from(“file:data/inbox?recursive=true&include=*.txt”)…

### AUTOMATIC TYPE CONVERTERS
Camel has a built-in type-converter mechanism that ships with more than 150 convert￾ers. You no longer need to configure type-converter rules to go from byte arrays to 
strings, for example. And if you find a need to convert to types that Camel doesn’t sup￾port, you can create your own type converter. The best part is that it works under the 
hood, so you don’t have to worry about it.
 The Camel components also leverage this feature; they can accept data in most 
types and convert the data to a type they’re capable of using. This feature is one of the 
top favorites in the Camel community. You may even start wondering why it wasn’t 
provided in Java itself! Chapter 3 covers more about type converters.

自动转换器

Camel有一个内置类型的转换器机制,它附带150多个转换器。您不再需要配置类型转换器规则来从字节数组转换为
例如字符串。如果您发现需要转换为Camel不支持的类型,您可以创建自己的类型转换器,所以你不用担心。
Camel组件也利用了这个特性;它们可以在大多数情况下接受数据
并将数据转换为他们能够使用的类型。此功能是
Camel社区的最爱。你甚至会开始怀疑为什么不是这样
Java本身提供!第3章介绍了有关类型转换器的更多信息。

### LIGHTWEIGHT CORE
Camel’s core can be considered pretty lightweight, with the total library coming in at 
about 1.6 MB and only having a dependency on Apache Commons Logging and Fuse Source Commons Management. This makes Camel easy to embed or deploy anywhere 
you like, such as in a standalone application, web application, Spring application, Java EE application, JBI container, OSGi bundle, Java Web Start, or on the Google App 
engine. Camel was designed not to be a server or ESB but instead to be embedded in 
whatever platform you choose.

轻量级核心

Camel的内核可以被认为是相当轻量级的,它的总库数为大约1.6MB,并且只依赖于Apache Commons Logging and Fuse。这使得Camel易于在任何地方嵌入或部署
你喜欢,比如在独立应用程序、web应用程序、Spring应用程序、javaee应用程序、JBI容器、OSGi包、javawebstart中,或者在Google应用程序上
引擎。Camel不是被设计成服务器或ESB,而是被嵌入到任何你选择的平台。

### TEST KIT 
Camel provides a Test Kit that makes it easier for you to test your own Camel applications. The same Test Kit is used extensively to test Camel itself, and it includes more 
than 6,000 unit tests. The Test Kit contains test-specific components that, for example, 
can help you mock real endpoints. It also contains setup expectations that Camel can 
use to determine whether an application satisfied the requirements or failed. Chapter 6 covers testing with Camel.

测试套件

Camel提供了一个测试工具包,使您能够更轻松地测试自己的Camel应用程序。同样的测试试剂盒被广泛用于测试Camel本身,它包括了更多
超过6000个单元测试。测试套件包含测试特定组件,例如,
可以帮助您模拟真实的端点。它还包含Camel可以实现的设置期望
用于确定应用程序是否满足要求或失败。第6章介绍了Camel的测试。

### VIBRANT COMMUNITY
Camel has an active community. This is essential if you intend to use any open source 
project in your application. Inactive projects have little community support, so if you 
run into issues, you’re on your own. With Camel, if you’re having any trouble, users 
and developers alike will come to your aid promptly. For more information on 
Camel’s community, see appendix D. 
 Now that you’ve seen the main features that make up Camel, we’ll get a bit more 
hands on by looking at the Camel distribution and trying out an example.

有活力的社区