Apache ActiveMQ, Camel, CXF and ServiceMix Overview
- 1. Apache
Ac6veMQ,
Camel,
CXF
&
ServiceMix
Overview
Open
Source
Integra6on
and
Messaging
Marcelo Jabali
Sr. Solutions Consultant
Sep., 2011
A
Progress
So3ware
Company
1
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 2. Agenda
§ Apache
Ac6veMQ
§ Apache
Camel
§ Apache
CXF
§ Apache
ServiceMix
§ FuseSource
Overview
2
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 3. About
Me
Marcelo
Jabali
FuseSource
marcelo@fusesource.com
marcelojabali.blogspot.com
mjabali
3
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 4. Apache
Ac6veMQ
§ A
high
performance,
reliable
messaging
fabric,
suppor6ng
JMS,
C,
.Net,
and
other
frameworks.
Clients connect to the
broker using Network
connectors with connectors control
simple URIs how the broker
interacts with other
brokers for
discovery,
replication,
Topics and queues
failover, clustering
created
and store &
dynamically.
forward.
… all based on a
flexible Spring-
File & JDBC-based
based core.
message stores
supported.
4
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 5. JMS
Fundamentals
Broker
<<Application>> <<Application>>
:JMSClient Produce Consume :JMSClient
message Destination message
Producer Consumer
§ The
JMS
specifica6on
defines
a
set
of
Java
interfaces
and
seman6cs
for
inter-‐applica6on
messaging
§ JMS defines two messaging models:
• Point-to-point (PTP)
• Publish and Subscribe (Pub/Sub)
5
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 6. Point-‐to-‐Point
Messaging
Model
Broker
Client A Queue
Produce Consume Client B
message message
§ With the Point-to-Point messaging model:
• Each message has only one and only consumer.
• There are no timing dependencies; consumers do not have
to be connected at the time the message is sent.
§ PTP is ideal for processing business transactions.
6
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 7. Publish
and
Subscribe
Messaging
Model
Client B
Broker
Client A Topic Client C
Produce Consume
message message
Client D
§ With the Pub/Sub messaging model:
• One message goes to zero-to-many consumers based on
the number of current subscribers
• Subscribers with an active subscription at the time the broker
gets the message receive a copy of the message
• Subscribers can be durable or non-durable
§ Pub/Sub is ideal for publishing business events.
7
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 8. JMS
Classes
and
Interfaces
§ These
are
the
classes
and
interfaces
that
you
use
to
program
the
JMS
client
applica6on
8
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 9. JMS
Messages
§ Messages
form
the
basic
unit
of
work
of
a
message
provider
§ They
are
simple
and
flexible
§ Basic
components
of
a
message:
• Header
(JMSDes6na6on,
JMSDeliveryMode,
JMSExpira6on,
etc)
• Proper6es
(op6onal)
–
User-‐defined
proper6es
• Body
(op6onal)
9
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 10. Ac6veMQ
Enhancements
to
JMS
§ Ac6veMQ
Connec6on
Factory
segngs
• disableTimeStampByDefault,
copyMessageOnSend,
useCompression,
objectMessageSerializa6onDefered,
useAsyncSend,
useRetroac6veConsumer
§ Des6na6ons
are
typically
created
on
demand
• They
can
also
be
created
at
the
broker
startup
§ Retroac6ve
Consumers
• Last
Image,
Fixed
Count
or
Fixed
Size
§ Des6na6on
Policies
• Dispatch policies – load balance consumers/producers
across destinations.
• Recovery Policies – recover messages/subscriptions.
• Pre-fetch policies – acknowledge messages sent to
consumers in batches.
10
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 11. Ac6veMQ
Enhancements
to
JMS
(cont.)
§ Advisory
Channels
• Starting and stopping consumers and producers
• Creating and destroying temporary destinations
• Expiring messages on topics and queues
• Sending messages from brokers to destinations with no
consumers
• Starting and stopping connections
§ Exclusive
Consumer
Priority
§ Message
Groups
§ Composite
&
Virtual
Des6na6ons
• Forward,
Route
&
High-‐Available
Load-‐Balanced
Durable
Subscribers
11
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 12. What
are
Network
of
Brokers?
§ In basic deployments, producers and consumers connect to the
same broker to exchange messages
§ With broker networks, messages not consumed locally are
forwarded broker-to-broker and dispatched to remote clients.
• The message can travel through multiple brokers before it is
consumed
• Each message is owned by a single broker at any point in time.
§ Broker networks allow you to scale your deployment by:
• Accommodating many more clients, e.g. when the number of
sockets is limited by the OS
• Increasing message throughput because messages are load-
balanced across all interested consumers.
• Distributing consumers and producers geographically across a
WAN, firewall or other bridges
12
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 13. Network
of
Brokers
-‐
Example
P A C
C
B
C
§ Brokers
A,
B
and
C
are
part
of
a
broker
network
§ There
is
a
producer
to
a
queue
on
broker
A
and
consumers
from
the
queue
on
brokers
A
and
B
§ Messages
sent
to
the
queue
are
dispatched
to
consumers
on
A
and
B;
messages
are
not
forwarded
to
C
• If
a
consumer
from
the
queue
starts
on
C,
messages
will
flow
there
as
well
13
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 14. Replica6on,
Clustering
&
Failover
Broker replication Shared message store
<<jvm>> <<jvm>>
frodo:ActiveMQ frodo:ActiveMQ
Master state Brokers
replicated to compete for
slave using file system or
network database
connector. lock.
<<jvm>> <<jvm>>
samwise:ActiveMQ samwise:ActiveMQ
14
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 15. Networks
Of
Master-‐Slave
Pairs
§ A
clustered,
highly
available
approach
<<jvm>> <<jvm>> <<jvm>>
frodo:ActiveMQ gandalf:ActiveMQ merry:ActiveMQ
Master
Slave
<<jvm>> <<jvm>> <<jvm>>
samwise:ActiveMQ saruman:ActiveMQ pip:ActiveMQ
15
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 16. Apache
Camel
§ Apache
Camel
is
a
powerful
Open
Source
Integra6on
Framework
based
on
known
Enterprise
Integra6on
Paqerns
http://enterpriseintegrationpatterns.com/
16
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 17. Apache
Camel
-‐
Paqerns
§ 50+
Enterprise
Integra6on
Paqerns
http://camel.apache.org/eip
17
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 18. Apache
Camel
–
Components,
Data
Formats
and
Languages
§ 80
Components
(ac6vemq,
bean,
cxf,
file,
3p,
hibernate,
jdbc,
iba6s,
jms,
jeqy,
mina,
neqy,
6mer,
xslt,
etc)
• http://camel.apache.org/components.html
§ 19
Data
Formats
(csv,
serializa6on,
zip,
hl7,
soap,
jaxb,
etc)
• http://camel.apache.org/data-format.html
§ 15
Expression
Languages
(EL,
Simple,
XQuery,
Xpath,
JavaScript,
Ruby,
Python,
PHP,
etc)
•
http://camel.apache.org/languages.html
18
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 19. Apache
Camel
-‐
Architecture
Camel can be
deployed in a wide An endpoint is a
Container
variety of container message source
types or sink
Camel context
Endpoints
The Camel context is
an instance of the
Camel runtime
environment
Components
A component is a plug-in endpoint factory;
Camel provides a wide variety of
components
19
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 20. Apache
Camel
§ Camel
provides
an
embedded
DSL
(in
Java,
Spring
or
Scala)
for
implemen6ng
enterprise
integra6on
paqerns
• The
DSL
uses
URIs
to
define
endpoints
which
are
combined
to
generate
integra6on
flows
20
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 21. Apache
Camel
§ Camel
Content-‐Based
Router
-‐
Spring
DSL
<camelContext>
<route>
<from uri="activemq:queue:NewOrders"/>
<choice>
<when>
<xpath>/order/product = 'widget'</xpath>
<to uri="activemq:Orders.Widgets"/>
</when>
<otherwise>
<to uri="activemq:Orders.Gadgets"/>
</otherwise>
</choice>
</route>
</camelContext>
21
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 22. Apache
Camel
§ Camel
Content-‐Based
Router
-‐
Java
DSL
from("activemq:queue:NewOrders")
.choice()
.when().xpath("/order/product = 'widget'")
.to("activemq:Orders.Widget")
.otherwise()
.to("activemq:Orders.Gadget");
22
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 23. Typical
Camel
Route
Development
Process
§ Use a Maven archetype to generate an outline project
§ Edit the POM to include additional dependencies
§ Add your Java code into src/main/java, and/or Spring
configuration to src/main/resources/META-INF/spring
§ Add instructions to the Maven Felix plugin, to assist in the generation
of OSGi manifest information
§ Test using the Camel Maven plugin
mvn camel:run
§ Deploy into the Apache ServiceMix OSGi container
• Drop into deploy/ directory (pre-production testing)
• Install a bundle/feature from a maven repository (production environment)
23
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 24. Apache
Camel
-‐
Example
§ Goals
•
Pickup
files
from
a
directory
•
Make
sure
we
only
pickup
3
files
per
30
seconds
•
Store
into
JMS
queue
•
Listen
on
JMS
queue
•
And
upload
file
to
FTP
server
24
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 25. Apache
Camel
–
Example
§ Camel
Route
Spring
XML
DSL
<camelContext>
<route>
<from uri="file:camellos/inbox?move=.done"/>
<throttle maximumRequestsPerPeriod="3"
timePeriodMillis="30000”>
<to uri="activemq:queue:camellos"/>
</throttle>
</route>
<route>
<from uri="activemq:queue:camellos"/>
<to uri="ftp://admin:secret@localhost:3333"/>
</route>
</camelContext>
25
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 26. Apache
CXF
§ Apache CXF is an open-source Java service framework
§ Full implementation of the JAX-WS 2.0 specification,
radically simplifying the process of exposing existing
Java code as a Web service or writing new Web
services.
§ Provides design-time tools and runtime infrastructure
that are technology-neutral.
§ Designed to work with variety of container servers,
languages, and messaging systems
§ Originally named Celtix and later moved to Apache
where it was merged with the Xfire project
26
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 27. Building
Applica6ons
with
CXF
§ CXF abstracts away the details of inter-process
communication between services and consumers.
• … allows developers to focus efforts on business logic rather
than integration logic.
§ CXF supports code-first and contract-first approaches:
• Expose “plain old Java objects” (POJOs) as a services, or
• Explicitly annotate Java classes, or
• Start with a WSDL contract.
§ Use CXF to develop both client- and server-side
components.
• Deploy as standalone Java applications, or easily integrate into
a Spring-based application
27
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 28. Apache
CXF
-‐
Architecture
§ CXF provides a layered communication stack to services
and consumers
28
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 29. Apache
CXF
-‐
Architecture
§ When a component sends a message to a service, it uses a Java API
derived from the WSDL contract
• The JAX-WS mapping is used.
• The Java API is protocol neutral.
§ A CXF binding creates the message payload
• Pure XML, SOAP, JSON, or some other message format.
§ Quality-of-service extensions can be added using message
interceptors
• CXF supports a number of Web Services QoS standards.
§ CXF then transmits the message using a transport.
• CXF includes HTTP, JMS, and AMQP out-of-the-box.
• You can write custom transports for CXF; for example: TCP, SMTP, FTP
29
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 30. CXF
Deployment
Model
§ CXF can also be deployed in a number of different
container technologies:
• In a Servlet engine (e.g. Tomcat)
• In a J2EE container (using bi-directional JCA) (e.g. JBOSS)
• In a JBI (Java Business Integration) container (e.g. ServiceMix)
• In an OSGi container (e.g. ServiceMix)
• Stand-alone JVM (e.g. java –jar myapp.jar)
§ This flexible deployment approach allows you to deploy
your CXF service-oriented components anywhere
30
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 31. Apache
ServiceMix
§ Full open source implementation of an Enterprise Service
Bus
• Based on OSGi technology (http://www.osgi.org)
§ Support for multiple component models
• OSGi bundles
• JBI artifacts
• Servlets
• Spring beans
• Camel routes (http://camel.apache.org)
• CXF web services and RESTful services (http://
cxf.apache.org)
• Extensible to support additional component models, such as EJB
31
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 32. Apache
ServiceMix
-‐
Architecture
§ ServiceMix employs a layered architecture based on OSGi
• The core : A lightweight runtime named “Karaf”, which extends
OSGi with powerful features for handling and managing OSGI
bundles
• The technology layer : A layer of component technologies that sits
on top of the core to support your applications
32
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 33. Apache
ServiceMix
–
Core
Layer
Features
§ Hot deployment support for OSGi bundles
§ Dynamic configuration of services through the OSGi
“ConfigurationAdmin” service
§ Dynamic logging back-end provided by Log4J supports different
APIs (SLF4J, Java Utils, JCL, Avalon, Tomcat, OSGi)
§ Application provisioning through file-drop, Maven repository and
remote download (http://)
§ Administration via an extensible shell console
§ Secure remote access via ssh
§ Security framework based on JAAS
33
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 34. Apache
ServiceMix
–
Technology
Layer
Features
§ Spring Framework
• ServiceMix loads an OSGi bundle into its runtime, or generates an OSGi
bundle on the fly, and then instantiates the Spring application context
§ JMS Message Broker
• ServiceMix deploys the Apache ActiveMQ broker (OSGi-ready)
§ JAX-WS/JAX-RS Web Services support
• ServiceMix deploys the Apache CXF runtime (OSGi-ready)
§ Enterprise Integration Patterns (EIP) support
• ServiceMix deploys the Apache Camel runtime (OSGi-ready)
§ Java Business Integration (JBI) support
• ServiceMix provides a JBI 1.0 container, to support legacy code
implemented as service units / service assemblies and deployed using
ServiceMix 3.x
§ Can be extended to support technologies such as SCA or EJB3
34
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 35. Apache
ServiceMix
–
Deployment
Model
§ When you deploy a ServiceMix solution, you typically
deploy the core (Karaf) plus one or more technology
components
§ Examples:
• To support EIPs : Karaf runtime + Camel feature
• To support JAX-WS/JAX-RS solutions : Karaf runtime + CXF
feature
• To support JMS solutions : Karaf runtime + ActiveMQ feature
• To support JBI-based solutions : Karaf runtime + JBI feature
35
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 36. FuseSource
Corpora6on
The
Leaders
in
Open
Source
Integra9on
and
Messaging
Produc9zed
distribu9ons
•
Integrated
Team
behind
the
projects
•
Tested
•
Leaders
at
Apache
•
Tooling
•
Product
roadmaps
•
Code
contribu9ons
Enterprise
support
•
Subscrip9ons
•
Training
•
Consul9ng
36
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 37. FuseSource
Subscrip6on
:
Cer6fied
Distribu6ons
Fuse
ESB
(ServiceMix),
Fuse
Message
Broker
(Ac9veMQ),
Fuse
Media9on
Router
(Camel),
Fuse
Services
Framework
(CXF)
• Tested
–
integrated
tests
on
supported
plasorms
• Produc6zed
distribu6ons
–
versioned,
supported
releases
• Freely
available
with
Apache
license
(can
edit
code
and
redistribute)
• Enterprise-‐class
distribu6ons
of
popular
apache
projects
37
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 38. Forrester
Wave
Report
Q2
2011:
Fuse
ESB
is
a
“Leader”
§ FuseSource
placed
in
“Leader”
category
in
company
with
large,
established
vendors
§ One
of
few
open
source
solu6ons
considered
for
this
report
§ Highest
ranked
open
source
solu6on
38
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 39. FuseSource
:
Team
that
Wrote
the
Code
No
one
knows
the
code,
or
influences
the
projects
at
Apache
more
than
FuseSource:
• Co-‐founders
and
PMC
members
of
ServiceMix,
Ac6veMQ,
Camel,
…
• Over
25
ac6ve
commiqers
on
11
Apache
projects
Guillaume
Nodet
James
Strachan
Rob
Davis
Hiram
Chirino
Dejan Gert
Jon
Anstey
Gary
Tully
Willem Jiang
Claus
Ibsen
Bosanac
Vanthienen
39
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 40. FuseSource
Subscrip6on
=
Long
Term
Success
Support
• Enterprise-‐class
24x7
coverage
• Global
organiza6on
• Mission-‐cri6cal
Influence
integra6on
exper6se
• Product
roadmaps
• Updates
and
migra6on
• Planning
processes
assistance
• Conduit
to
Apache
Tools
• Development
• Opera6ons
• Management
• Performance
• Documenta6on
40
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company
- 41. Thanks!
No
vendor
lock-‐in
Free
to
redistribute
Enterprise
class
A
Progress
So3ware
Company
41
Copyright
©
2011
Progress
So3ware
Corpora6on
and/or
its
subsidiaries
or
affiliates.
All
rights
reserved.
A
Progress
So3ware
Company