Вы находитесь на странице: 1из 5

Building complex systems from scratch is a very costly endeavor, and one thats

almost
never successful. An efective and less risky alternative is to assemble a system
like a
jigsaw pule from existing, proven components
Introducing Camel
!amel is an integration framework that aims to make your integration projects
productive
and fun.
At the core of the !amel framework is a routing engine, or more precisely a
routingengine
builder. "t allows you to de#ne your own routing rules, decide from which
sources to accept messages, and determine how to process and send those
messages to
other destinations.
$ne of the fundamental principles of !amel is that it makes no assumptions about
the type of data you need to process. %his is an important point, because it gives
you,
the developer, an opportunity to integrate any kind of system, without the need to
convert your data to a canonical format.
!amel can route any kind of payload&you arent restricted to carrying '()
payloads.
%his freedom means that you dont have to transform your payload into a
canonical
format to facilitate routing.
"ts extensible and modular architecture allows you to implement
and seamlessly plug in support for your own protocols, proprietary or not
*e should also mention what !amel isnt. !amel isnt an enterprise service bus
+,-B., although some call !amel a lightweight ,-B because of its support for
routing,
transformation, monitoring, orchestration, and so forth. !amel doesnt have a
container or a reliable message bus, but it can be deployed in one, such as $pen/
,-B or the previously mentioned -ervice(ix. 0or that reason, we prefer to call
!amel an integration framework rather than an ESB.
Why Camel
1outing and mediation engine
,nterprise integration patterns +,"2s.
3omain/speci#c language +3-).
,xtensive component library
2ayload/agnostic router
(odular and pluggable architecture
2$4$ model
,asy con#guration
Automatic type converters
)ightweight core
%est kit
5ibrant community
1.3.1 Message
%he fundamental entity containing the data being carried and routed in !amel
(essage -tructure
6eader //7 (ap
Attachment //7 +optional. 8se in mail and web service
Body //7 %ype $bject. %hat means that a message can store any kind
of content.
1.3.2 Exchange
An exchange in !amel is the messages container during routing. ,xchange
support (essage ,xchange 2attern+(,2. . (,29s are used to diferentiate between
one/way and re:uest/response messaging styles.
6igh )evel architrave of !amel
!amel !ontext
!amel context known as camel runtime. which keeps all the pieces together
The CamelContext provides access to many useful services, the most notable being
components, type converters, a registry, endpoints, routes, data formats, and languages
SERVICE Description
C!"#E#
TS
!ontains the components used. !amel is capable of loading components on the ;y
either by autodiscovery on the classpath or when a new bundle is activated in an
$-<i
container
E#D"I#TS
!ontains the endpoints that have been created
R$TES
!ontains the routes that have been added.
T%"E
C#VERTER
S
!ontains the loaded type converters. !amel has a mechanism that allows you to
manually
or automatically convert from one type to another.
D&T&
!ontains the loaded data formats
'R!&TS
RE(ISTR%
!ontains a registry that allows you to look up beans. By default, this will be a 4=3"
registry.
"f youre using !amel from -pring, this will be the -pring ApplicationContext. "t
can
also be an $-<i registry if you use !amel in an $-<i container
)&#($&(E
!ontains the loaded languages. !amel allows you to use many diferent languages
to
create expressions. >oull get a glimpse of the '2ath language in action when we
cover
the 3-)
1$8%"=< ,=<"=,
!amels routing engine is what actually moves messages under the hood. %his
engine
isnt exposed to the developer, but you should be aware that its there and that it
does
all the heavy lifting, ensuring that messages are routed properly.
1$8%,-
1outes are obviously a core abstraction for !amel. %he simplest way to de#ne a
route
is as a chain of processors. %here are many reasons for using routers in
messaging applications.
By decoupling clients from servers, and producers from consumers, routes can
3ecide dynamically what server a client will invoke
2rovide a ;exible way to add extra processing
Allow for clients and servers to be developed independently
Allow for clients of servers to be stubbed out +using mocks. for testing purposes
0oster better design practices by connecting disparate systems that do one
thing well
,nhance features and functionality of some systems +such as message brokers
and ,-Bs.
,ach route in !amel has a uni:ue identi#er thats used for logging, debugging,
monitoring,
and starting and stopping routes. 1outes also have exactly one input source for
messages, so theyre efectively tied to an input endpoint.
%o de#ne a route, a 3-) is used.
3$(A"=/-2,!"0"! )A=<8A<, +3-).
%o wire processors and endpoints together to form routes, !amel de#nes a 3-).
%he
term DSL is used a bit loosely here. "n !amel, 3-) means a ;uent 4ava A2" that
contains
methods named for ,"2 terms.
!onsider this example?
from("file:data/inbox")
.filter().xpath("/order[not(@test)]")
.to("jms:queue:order")
21$!,--$1
%he processor is a core !amel concept that represents a node capable of using,
creating,
or modifying an incoming exchange.
!$(2$=,=%
!omponents are the main extension point in !amel.0rom a programming point of
view, components are fairly simple? theyre associated with a name thats used in
a 81", and they act as a factory of endpoints.
,=32$"=%
An endpoint is the !amel abstraction that models the end of a channel through
which a system can send or receive messages.
"n !amel, you con#gure endpoints using 81"s, such as file:data/inbox?
delay=5000, and you
also refer to endpoints this way. At runtime, !amel will look up an endpoint based
on the 81" notation.
%he scheme one +@. denotes which !amel component handles that type of
endpoint. "n this case, the scheme of file selects the FileComponent. %he
FileComponent then works as a factory creating the FileEndpoint based on the
remaining parts of the 81".
*hen a message needs to be sent to an endpoint, the producer will create an
exchange and populate it with data compatible with that particular endpoint. 0or
example, a FileProducer will write the message body to a #le. A JmsProducer,
on the other hand, will map the !amel message to a javax.jms.Message before
sending it to a 4(- destination. %his is an important feature
in !amel, because it hides the complexity of interacting with particular transports

Вам также может понравиться