Camel in action Reading Notes Chapter 1 Introduction to camel 1.1 camel

Source: Internet
Author: User
Tags enterprise integration patterns apache camel
1.1 camel introduction camel is an integrated framework designed to make project integration more efficient and interesting. The Camel project started in early 2007 and is relatively young, but it is already a very mature open-source project. It uses Apache 2 open-source license, and the community behind it is very powerful. Camel aims to simplify integration. After reading this book carefully, you will be grateful to camel for using it as a required skill. The main reason why the Apache camel project is named camel is that it is easy to remember. One of the Project creators is inspired by the smoke of a "Camel" brand. Regarding the origin of the name, a FAQ on the camel website explains why the name is named camel. 1.1.1 what is camel? The core of camel is a routing engine. More specifically, it is a route engine builder that allows you to define routing rules by yourself, this includes where to receive the message, how to process it, and where to send it. Camel's integrated language allows you to write powerful and fine-grained routing rules, just like a business processing process. One basic principle of camel is that it doesn't care what type of data you want to process. This is extremely important. For you or developers, this means that integration of any system is possible without converting your data type to a standard format. The high abstraction of camel allows you to use the same API between different protocols and data types. Components in camel) specific implementations are made for different protocols and data types. Surprisingly, it supports more than 80 protocols and data types [1]. Its Modular Design and scalability allow you to implement your own component, this architecture design saves unnecessary conversions and makes camel faster and lighter. Therefore, it is a great choice to embed camel into projects with rich processing capabilities such as camel. For example, other open-source projects Apache ServiceMix and activemq use camel for system integration. Let's talk about camel. Camel is not an Enterprise Service Bus (ESB), but some people still say it is a lightweight ESB because it can do routing and data conversion, however, camel does not have a container or a reliable message bus. However, we can choose to deploy it in such an environment as open ESB and ServiceMix. So we regard it as an integration framework rather than an ESB. To better understand what camel is, let's take a look at its main features. 1.1.2 why use camel? Camel has many novel ideas in the integration field, which is why its creators want to create camel instead of using a ready-made framework. We will learn about camel in this book. The general idea behind camel is: * mediation engine * enterprise integration mode (EIPs) * domain-specific language (DSL) * scalable component package * message content that does not care about routing * Modular and pluggable architecture design * pojo model * easy to configure * Type Automatic converter * lightweight core * test suite * full then, let's take a look at these features: the core feature of the routing mediation engine camel is its routing mediation engine. A routing engine can choose to forward messages based on routing rules. In the world of camel, the configuration of router routing rule [2] should use eip and DSL. Next we will introduce in detail. Although the enterprise integration model has diversified problems, Gregor hohpe and Bobby Woolf have found that these problems and solutions can be summarized in a unified manner, for this reason, they wrote a book enterprise integration patterns that everyone wants to integrate. If you haven't had time to read it, we recommend that you learn it first. At least it helps you understand camel concepts more quickly. EIPs are useful not only because there is a solution for each integration class problem, but also helps you understand the problem itself. This mode summarizes some faster problem solving rules. The difference between the use mode and the manual solution is like a verbal communication or a sign language communication. If you have been abroad, you can feel this difference. Camel is largely implemented based on EIPs. Although EIPs describes many integration problems and solutions, it is only a solution. Camel uses a language to implement these ideas. The modes in EIPs are similar to those in camel DSL. The DSL of camel, a specific language in the field, has made great contributions to the Integration field. Some other frameworks may also provide DSL features (for example, XML can be used to define routing rules ), however, unlike camel DSL, which is based on custom languages. Camel is unique because it provides DSL for common programming languages, such as Java, Scala, and groovy. It also provides XML to describe routing rules. DSL aims to allow developers to focus on integration issues, rather than the use of a programming language. Although camel is mostly written in Java, it still supports mixed programming in multiple languages. Each language has its own advantages. You may want to do different things in different languages. Using camel allows you to build your own solutions freely. Below are examples of DSL in different languages. They all do the same thing. * Java DSL
From ("file: Data/inbox"). To ("JMS: queue: Order ");
* Spring DSL
<route><from uri="file:data/inbox"/><to uri="jms:queue:order"/></route>
* Scala DSL
from "file:data/inbox" -> "jms:queue:order"
These examples are all real and runable code. They show that it is easy to forward the files in data/inbox to the JMS queue order. These are all about using DSL in actual programming. You can use some current tools to help you complete code and compile error prompts, for example, 1.1 is the Eclipse IDE Code Completion to help you prompt which DSL can be used. The scalable component package camel provides more than 80 components that allow camel to connect to different transport, or use different APIs or identify different data types. Camel can route messages in different forms, not just in XML format. You do not need to convert your contents into a standard format during routing. Modular and pluggable architecture design the modular design of camel can load any component to the runtime environment of camel without considering whether these component are provided by camel itself, it can be provided by a third party or customized by you. Pojo models in camel, beans (or pojo) are treated as first-class citizens, and camel strives to make beans available anywhere in the Project Integration at any time, this means that you can extend the built-in functions of camel to your own code. In Chapter 4 of this book, we will give a complete explanation of bean in camel. Ease of configuration the configuration task can be reduced based on the Convention over configuration principle. In order to directly configure the endpoint in the routing (rourte, camel provides user-friendly configuration. For example:
from("file:data/inbox?recursive=true&include=*.txt")...
Camel has more than 150 built-in type conversion mechanisms. For example, you do not need to configure a type converter to convert byte arrays into strings, if you need a converter that is not available in camel, You need to define it yourself. But don't worry, the popular conversion tools Camel have been implemented. Simple core the core of camel is very lightweight. The entire package is only 1.6 Mb, and it only depends on Apache commons logging and fuse source commons management. This is enough for you to deploy or embed camel anywhere, such as a standalone application, web application, spring application, Java EE application, jbi container [3], osgi bundle, java Web Start or Google App Engine. Therefore, camel is not designed as a server or ESB, but a platform that can be embedded in any platform you want to use. The test suite is provided to test your camel program. Camel provides a Test Suite, which is widely used by itself and has more than 6000 [4] unit test cases, test kit contains dedicated test components. For example, it can use Mock's real endpoints and provide expectation to determine whether the program runs as expected. In chapter 6 of this book, we will detail how to test camel. A dynamic community is a must for you to plan to use open-source software in your applications. inactive open-source projects are generally not a good community, once you encounter problems, you can only fight for it. If you encounter problems when using camel, camel users and camel developers will actively help you. For more information about the camel community, see appendix D. Now you have browsed the main features of camel. Next, let's take a look at the camel installation package and try a simple example. [1] with the development of the project, 161 protocols and data types have been supported. For more precise data, see https://github.com/apache/camel/tree/master/components4242] routing rules can be defined as routers. [3] Not so popular [4] Please read the source code for specific values

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.