SlideShare a Scribd company logo
1 of 35
AAppaacchhee AAccttiivveeMMQQ
Contents 
1. Introduction 
2. About JMS 
3. Messaging Domains 
4. Why ActiveMQ? 
5. Benefits
Introduction 
ā— ActiveMQ is used in enterprise service bus 
implementations such as Apache ServiceMix and 
Mule. 
ā— Apache ActiveMQ is a message broker which fully 
implements the Java Messaging Service API. It can 
be used by programs written Java,C/C++,.NET,PHP 
etc.
JMS (Java Messaging Service) 
The Java Message Service (JMS) API is a Java Message Oriented Middleware (MOM) 
API for sending messages between two or more clients. It is a messaging standard that 
allows application components based on the Java Enterprise Edition (Java EE) to 
create, send, receive, and read messages. An application can communicate with any 
number of applications using JMS.This communication is loosely coupled. Instead, 
those applications are communicated by connecting to a common destination. An 
application can send messages to the destination and can take messages from the 
same destination.The concept is shown below as a schematic.This technology is too 
simple and it can be easily integrated with existing applications so that those 
applications can communicate each other.
Destination 
Type 
Description 
Topic In JMS a Topic implements publish and subscribe semantics. When you 
publish a message it goes to all the subscribers who are interested - so zero 
to many subscribers will receive a copy of the message. Only subscribers 
who had an active subscription at the time the broker receives the message 
will get a copy of the message. 
Queue A JMS Queue implements load balancer semantics. A single message will be 
received by exactly one consumer. If there are no consumers available at the 
time the message is sent it will be kept until a consumer is available that can 
process the message. If a consumer receives a message and does not 
acknowledge it before closing then the message will be redelivered to 
another consumer. A queue can have many consumers with messages load 
balanced across the available consumers.
JMS Sessions 
A session is a single-threaded context for producing and consuming messages. We use 
sessions to create the following: 
ā— Message producers 
ā— Message consumers 
ā— Messages 
ā— Destination 
When a client creates a JMS session it must specify the mode in which the Session will 
acknowledge the messages that it receives and dispatches. The modes supported are 
summarized in the table below.
Acknowledge 
Mode 
Description 
AUTO_ACKNOWL 
EDGE 
With this acknowledgement mode, the session automatically acknowledges 
a client's receipt of a message either when the session has successfully 
returned from a call to receive or when the message listener the session has 
called to process the message successfully returns. 
CLIENT_ACKNOW 
LEDGE 
With this acknowledgement mode, the client acknowledges a consumed 
message by calling the message's acknowledge method. Acknowledging a 
consumed message acknowledges all messages that the session has 
consumed. When client acknowledgement mode is used, a client may build 
up a large number of unacknowledged messages while attempting to 
process them. A JMS provider should provide administrators with a way to 
limit client overrun so that clients are not driven to resource exhaustion and 
ensuing failure when some resource they are using is temporarily blocked. 
DUPS_OK_ACKN 
OWLEDGE 
This acknowledgement mode instructs the session to lazily acknowledge the 
delivery of messages. This is likely to result in the delivery of some duplicate 
messages if the JMS provider fails, so it should only be used by consumers 
that can tolerate duplicate messages. Use of this mode can reduce session 
overhead by minimizing the work the session does to prevent duplicates. 
SESSION_TRANS 
ACTED 
Session is Transacted and the acknowledge of messages is handled 
internally. 
INDIVIDUAL_ACK 
NOWLEDGE 
Acknowledges are applied to a single message only. Unlike 
CLIENT_ACKNOWLEDGE where the acknowledgement applies to all 
messages received up to that point for the entire session, this mode applied 
only to a single message allowing the client to be more selective about 
which messages are acknowledged.
Messaging Domains 
JMS API supports Point-to-Point and Publish-Subscribe approaches. 
Point-to-Point Approach : 
The point to point approach consists of a sender , a receiver and a queue.The sender 
addresses a message to the queue, and the receiving clients extract messages from the 
queues established to hold their messages. The queue keeps the message till a receiving 
client receives it or till the message expires. While any number of producers can send 
messages to the queue, each message is guaranteed to be delivered, and consumed by 
one consumer.
Publish/Subscribe Approach : 
The publish/subscribe model supports publishing messages to a particular message topic. 
Subscribers may register interest in receiving messages on a particular message topic. In 
this model, neither the publisher nor the subscriber knows about each other. A good analogy 
for this is an anonymous bulletin board. 
ā— Zero or more consumers will receive the message. 
ā— There is a timing dependency between publishers and subscribers. The publisher 
has to create a message topic for clients to subscribe. The subscriber has to remain 
continuously active to receive messages, unless it has established a durable 
subscription. In that case, messages published while the subscriber is not connected 
will be redistributed whenever it reconnects.
A JMS message has 3 parts 
a)header :- The header contains meta-information about the messageā€” 
who sent it, where itā€™s going, and so on. 
b)body :- As the name suggests it is the body of messages. JMS API allows five 
types of message bodies. 
1. TextMessage :- Body contains String data 
2. ByteMessage :- Body contains byte data 
3. MapMessage :- Body contains data in key/value pair 
4. StreamMessage :-Body contains a stream of primitive values 
5. ObjectMessage : ā€“ Body contains an object 
6. Message :- Nothing in body. Only header and properties. 
c)properties :- Additional properties other than header.
Why Messaging as Communication Style? 
ā— File Transfer and Shared Database enable applications to share their data 
but not their functionality. 
ā— Remote Procedure Invocation enables applications to share functionality, but 
it tightly couples them as well. Often the challenge of integration is about 
making collaboration between separate systems as timely as possible, 
without coupling systems together in such a way that they become unreliable 
either in terms of application execution or application development. 
ā— The data transfer should be asynchronous so that the sender does not need 
to wait on the receiver, especially when retry is necessary. 
ā— Use Messaging to transfer packets of data frequently, immediately, reliably, 
and asynchronously, using customizable formats.
Why ActiveMQ? 
Imagine you need to communicate with two or more systems. A common 
approach these days will be web services which is fine if you need an answers 
right away. 
However: web services can be down and not available - what do you do then? 
Putting your message into a message queue (which has a component on your 
machine/server, too) typically will work in this scenario - your message just 
doesn't get delivered and thus processed right now - but it will later on, when 
the other side of the service comes back online. 
The Message Queue receives the message, places it in the proper queue, and 
waits for the application to retrieve the message when ready.
Connect an application to a messaging channel using a Message Endpoint, a 
client of the messaging system that the application can then use to send or 
receive Messages.We need a message endpoint to connect the system 
explicitly to the integration solution. The endpoint can be a special piece of code 
or a channel adapter provided by an integration software vendor. 
For example, one data format may store the customer name in two fields, called 
FIRST_NAME and LAST_NAME, while the other system may use a single field 
called Customer_Name. Likewise, one system may support multiple customer 
addresses while the other system only supports a single address. Because the 
internal data format of an application can often not be changed the middleware 
needs to provide some mechanism to convert one applicationā€™s data format in 
the otherā€™s. We call this step translation.
So far we can send data from one system to another and accommodate 
differences in data formats. What happens if we integrate more than two 
systems? Where does the data have to be moved? We could expect each 
application to specify the target system(s) for the data it is sending over the 
channel. For example, if the customer address changes in the customer care 
system we could make that system responsible for sending the data to all other 
systems that store copies of the customer address. As the number of systems 
increases this becomes very tedious and requires the sending system to have 
knowledge about all other systems. Every time a new system is added, the 
customer care system would have to be adjusted to the new environment. 
Things would be a lot easier of the middleware could take care of sending 
messages to the correct places. This is the role of a routing component such as 
a message broker. 
Integration solutions can quickly become complex because they deal with 
multiple applications, data formats, channels, routing and transformation. All 
these elements may be spread across multiple operating platforms and 
geographic locations. In order to have any idea what is going on inside the 
system we need a systems management function. This subsystem monitors the 
flow of data, makes sure that all applications and components are available and 
reports error conditions to a central location.
When a standard message is sent to a queue from a producer, it is sent to the broker, 
which persists it in its message store. By default this is in KahaDB, but it can configured to 
be stored in memory, which buys performance at the cost of reliability. Once the broker 
has confirmation that the message has been persisted in the journal (the terms journal and 
message store are often used interchangeably), it responds with an acknowledgement 
back to the producer. The thread sending the message from the producer is blocked at this 
time.
On the consumption side, when a message listener is registered or a call to receive() is 
made, the broker creates a subscription to that queue. Messages are fetched from the 
message store and passed to the consumer; itā€™s usually done in batches, and the fetching 
is a lot more complex than simply read from disk, but thatā€™s the general idea. With the 
default behaviour, assuming the Session.AUTO_ACKNOWLEDGE is being used, the 
consumer will acknowledge that the message has been received before processing it. On 
receiving the acknowledgement, the broker updates the message store marking that 
message as consumed, or just deletes it (this depends on the persistence mechanism).
This figure also illustrates two important messaging concepts: 
1. Send and forget 
ā€”In step 2, the sending application sends the message to the message channel. 
Once that send is complete, the sender can go on to other work while the 
messaging system transmits the message in the background. The sender can be 
confident that the receiver will eventually receive the message and does not 
have to wait until that happens. 
2. Store and forward 
ā€”In step 2, when the sending application sends the message to the message 
channel, the messaging system stores the message on the senderā€™s computer, 
either in memory or on disk. In step 3, the messaging system delivers the 
message by forwarding it from the senderā€™s computer to the receiverā€™s computer, 
and then stores the message once again on the receiverā€™s computer. This store-and- 
forward process may be repeated many times as the message is moved 
from one computer to another until it reaches the receiverā€™s computer.
Benefits : 
Using messaging as an integration or communication style leads to many benefits such as: 
ā— Allowing applications built with different languages and on different operating systems to 
integrate with each other 
ā— Location transparency ā€“ client applications donā€™t need to know where the service 
applications are located 
ā— Reliable communication ā€“ the producers/consumers of messages donā€™t have to be 
available at the same time, or certain segments along the route of the message can go 
down and come back up without impacting the message getting to the service/consumer 
ā— Scaling ā€“ can scale horizontally by adding more services that can handle the messages if 
too many messages are arriving 
ā— Asynchronous communication ā€“ a client can fire a message and continue other 
processing instead of blocking until the service has sent a response; it can handle the 
response message only when the message is ready 
ā— Reduced coupling ā€“ the assumptions made by the clients and services are greatly 
reduced as a result of the previous 5 benefits. A service can change details about itself, 
including its location, protocol, and availability, without affecting or disrupting the client.
AAppaacchhee CCaammeell
Contents 
1) Introduction 
2) About Camel 
3) Messaging Models 
4) Example 
5) Architecture
Introduction 
ā— Apache Camel ā€œa powerful open source integration framework based on 
known Enterprise Integration Patterns with powerful Bean Integrationā€. 
ā— Camel is a mediation and routing engine that lets you implement EIPā€™s. It 
uses a simple URI notation to identify the different transport and messaging 
models. 
ā— Camel is open-source integration framework which allows you to build routes 
for integration scenario's quickly and efficiently. You can deploy these routes 
directly on ServiceMix by deploying the plain Spring XML route or by 
packaging the route in an OSGi bundle. 
ā— The best thing about Camel is that it can be embedded into your current java 
application to implement integrations. On a larger scale Camel is part of 
Apache ServiceMix ESB. 
ā— The Camel project was started in early 2007.
About Camel 
ā— Building complex systems from scratch is a very costly endeavor, and one 
thatā€™s almost never successful. Apache Camel is such an integration 
framework that provides simple, manageable abstractions for the complex 
systems youā€™re integrating and the ā€œglueā€ for plugging them together 
seamlessly. 
ā— Camelā€™s most important features: message routing. At the core of the Camel 
framework is a routing engine, or more precisely a routing engine builder. It 
allows you to define your own routing rules, decide from which sources to 
accept messages, and determine how to process and send those messages 
to other destinations. 
For example: JMS -> JSON, HTTP -> JMS or funneling FTP -> JMS, HTTP 
-> JMS, JSON -> JMS
ā— Camel has two main ways of defining routing rules: the Java-based domain 
specific language (DSL) and the Spring XML configuration format. 
ā— One of the fundamental principles of Camel is that it makes no assumptions 
about the type of data you need to process. This 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. 
ā— Camel isnā€™t an enterprise service bus(ESB), although some call Camel a 
lightweight ESB because of its support for routing, transformation, 
monitoring, orchestration, and so forth. Camel doesnā€™t have a container or a 
reliable message bus, but it can be deployed in one, such as Open-ESB or 
the ServiceMix. For that reason, we prefer to call Camel an integration 
framework rather than an ESB. Camel was designed not to be a server or 
ESB but instead to be embedded in whatever platform you choose.
Camelā€™s message model 
In Camel, there are two abstractions for modeling messages, 
ā–  org.apache.camel.Message 
ā€”The fundamental entity containing the data being carried and routed in Camel. 
ā€”The Message interface provides an abstraction for a single message, such as a 
request, reply or exception message. In Camel terminology, the request, reply and 
exception messages are called in, out and fault messages. 
ā–  org.apache.camel.Exchange 
ā€”The Camel abstraction for an exchange of messages. This exchange of messages 
has an ā€œinā€ message and as a reply, an ā€œoutā€ message. 
ā€”The Exchange interface provides an abstraction for an exchange of messages, 
that is, a request message and its corresponding reply or exception message.
Example on Routing Files: 
Suppose you need to read files from one directory (data/inbox), process them in 
some way, and write the result to another directory (data/outbox). For simplicity, 
youā€™ll skip the processing, so your output will be merely a copy of the original file. 
Below figure illustrates this process. 
It looks pretty simple, right? Hereā€™s a possible solution using pure Java (with no 
Camel) but it still results in 34 lines of code. You have to use low-level file APIs 
and ensure that resources get closed properly, a task that can easily go wrong. 
But if an integration framework like Apache Camel is used, we can create a file-polling 
route in just one line of Java code
Architecture
CamelContext 
A CamelContext object represents the Camel runtime system. 
CamelContext is the heart of Camel its where all the routes, endpoints, 
components, etc. is registered. You typically have one CamelContext object in 
an application. A typical application executes the following steps. 
ā— Create a CamelContext object. 
ā— Add endpoints ā€“ and possibly Components, to the CamelContext object. 
ā— Add routes to the CamelContext object to connect the endpoints. 
ā— Invoke the start() operation on the CamelContext object. This starts 
Camel-internal threads that are used to process the sending, receiving and 
processing of messages in the endpoints. 
ā— Eventually invoke the stop() operation on the CamelContext object. Doing 
this gracefully stops all the endpoints and Camel-internal threads.
Components 
Component is confusing terminology; EndpointFactory would have 
been more appropriate because a Component is a factory for 
creating Endpoint instances. 
Processor 
The Processor interface represents a class that processes a 
message. Notice that the parameter to the process() method is 
an Exchange rather than a Message. 
RouteBuilders 
A route is the step-by-step movement of a Message from an input 
queue, through arbitrary types of decision making (such as filters 
and routers) to a destination queue (if any). A DSL wires Endpoints 
and Processors together to form routes. Camel provides two ways 
for an application developer to specify routes. One way is to specify 
route information in an XML file. A discussion of that approach is 
outside the scope of this document. The other way is through what 
Camel calls a Java DSL (domain-specific language).
Here are some examples of the DSL using different languages and staying functionally 
equivalent: 
ī€Š 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 real code, and they show how easily you can route files from a folder to a 
JMS queue.
Content Based Router 
The Content Based Router from the EIP patterns allows you to route 
messages to the correct destination based on the contents of the 
message exchanges. 
The Content-Based Router examines the message content and routes 
the message onto a different channel based on data contained in the 
message.
Message Filter 
The Message Filter from the EIP patterns allows you to filter messages. 
The Message Filter has only a single output channel. If the message 
content matches the criteria specified by the Message Filter, the 
message is routed to the output channel. If the message content does 
not match the criteria, the message is discarded.
Thank You

More Related Content

What's hot

Maven Overview
Maven OverviewMaven Overview
Maven Overview
FastConnect
Ā 

What's hot (20)

Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
Ā 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
Ā 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
Ā 
Spring Boot & Actuators
Spring Boot & ActuatorsSpring Boot & Actuators
Spring Boot & Actuators
Ā 
Introduction aĢ€ spring boot
Introduction aĢ€ spring bootIntroduction aĢ€ spring boot
Introduction aĢ€ spring boot
Ā 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
Ā 
Architecture jee principe de inversion de controle et injection des dependances
Architecture jee principe de inversion de controle et injection des dependancesArchitecture jee principe de inversion de controle et injection des dependances
Architecture jee principe de inversion de controle et injection des dependances
Ā 
Low Code Integration with Apache Camel.pdf
Low Code Integration with Apache Camel.pdfLow Code Integration with Apache Camel.pdf
Low Code Integration with Apache Camel.pdf
Ā 
promgen - prometheus managemnet tool / simpleclient_java hacks @ Prometheus c...
promgen - prometheus managemnet tool / simpleclient_java hacks @ Prometheus c...promgen - prometheus managemnet tool / simpleclient_java hacks @ Prometheus c...
promgen - prometheus managemnet tool / simpleclient_java hacks @ Prometheus c...
Ā 
Spring boot
Spring bootSpring boot
Spring boot
Ā 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
Ā 
Support distributed computing and caching avec hazelcast
Support distributed computing and caching avec hazelcastSupport distributed computing and caching avec hazelcast
Support distributed computing and caching avec hazelcast
Ā 
Spring Boot
Spring BootSpring Boot
Spring Boot
Ā 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Ā 
Formation jpa-hibernate-spring-data
Formation jpa-hibernate-spring-dataFormation jpa-hibernate-spring-data
Formation jpa-hibernate-spring-data
Ā 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
Ā 
Why Vue.js?
Why Vue.js?Why Vue.js?
Why Vue.js?
Ā 
Maven Overview
Maven OverviewMaven Overview
Maven Overview
Ā 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
Ā 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.js
Ā 

Viewers also liked

Messaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQMessaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQ
dejanb
Ā 
Apache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in actionApache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in action
dejanb
Ā 
ActiveMQ In Action
ActiveMQ In ActionActiveMQ In Action
ActiveMQ In Action
Bruce Snyder
Ā 
Messaging With Apache ActiveMQ
Messaging With Apache ActiveMQMessaging With Apache ActiveMQ
Messaging With Apache ActiveMQ
Bruce Snyder
Ā 
System Integration with Akka and Apache Camel
System Integration with Akka and Apache CamelSystem Integration with Akka and Apache Camel
System Integration with Akka and Apache Camel
krasserm
Ā 
Apache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixApache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMix
Bruce Snyder
Ā 
Apache ķ•µģ‹¬ ķ”„ė”œģ ķŠø camel ģ—æė³“źø°
Apache ķ•µģ‹¬ ķ”„ė”œģ ķŠø camel ģ—æė³“źø°Apache ķ•µģ‹¬ ķ”„ė”œģ ķŠø camel ģ—æė³“źø°
Apache ķ•µģ‹¬ ķ”„ė”œģ ķŠø camel ģ—æė³“źø°
Hwang Sun Oh Kelly
Ā 
Enterprise Integration Patterns with ActiveMQ
Enterprise Integration Patterns with ActiveMQEnterprise Integration Patterns with ActiveMQ
Enterprise Integration Patterns with ActiveMQ
Rob Davies
Ā 

Viewers also liked (20)

Messaging With ActiveMQ
Messaging With ActiveMQMessaging With ActiveMQ
Messaging With ActiveMQ
Ā 
Messaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQMessaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQ
Ā 
Apache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in actionApache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in action
Ā 
ActiveMQ In Action
ActiveMQ In ActionActiveMQ In Action
ActiveMQ In Action
Ā 
Advanced messaging with Apache ActiveMQ
Advanced messaging with Apache ActiveMQAdvanced messaging with Apache ActiveMQ
Advanced messaging with Apache ActiveMQ
Ā 
Getting Started with Apache Camel at DevNation 2014
Getting Started with Apache Camel at DevNation 2014Getting Started with Apache Camel at DevNation 2014
Getting Started with Apache Camel at DevNation 2014
Ā 
Messaging With Apache ActiveMQ
Messaging With Apache ActiveMQMessaging With Apache ActiveMQ
Messaging With Apache ActiveMQ
Ā 
Active MQ
Active MQActive MQ
Active MQ
Ā 
Developing Microservices with Apache Camel
Developing Microservices with Apache CamelDeveloping Microservices with Apache Camel
Developing Microservices with Apache Camel
Ā 
Polyglot Messaging with Apache ActiveMQ
Polyglot Messaging with Apache ActiveMQPolyglot Messaging with Apache ActiveMQ
Polyglot Messaging with Apache ActiveMQ
Ā 
System Integration with Akka and Apache Camel
System Integration with Akka and Apache CamelSystem Integration with Akka and Apache Camel
System Integration with Akka and Apache Camel
Ā 
Apache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixApache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMix
Ā 
Apache Camel workshop at BarcelonaJUG in January 2014
Apache Camel workshop at BarcelonaJUG in January 2014Apache Camel workshop at BarcelonaJUG in January 2014
Apache Camel workshop at BarcelonaJUG in January 2014
Ā 
Getting started with Apache Camel - jDays 2013
Getting started with Apache Camel - jDays 2013Getting started with Apache Camel - jDays 2013
Getting started with Apache Camel - jDays 2013
Ā 
Infrastructure as Code
Infrastructure as CodeInfrastructure as Code
Infrastructure as Code
Ā 
Apache ķ•µģ‹¬ ķ”„ė”œģ ķŠø camel ģ—æė³“źø°
Apache ķ•µģ‹¬ ķ”„ė”œģ ķŠø camel ģ—æė³“źø°Apache ķ•µģ‹¬ ķ”„ė”œģ ķŠø camel ģ—æė³“źø°
Apache ķ•µģ‹¬ ķ”„ė”œģ ķŠø camel ģ—æė³“źø°
Ā 
Enterprise Integration Patterns with ActiveMQ
Enterprise Integration Patterns with ActiveMQEnterprise Integration Patterns with ActiveMQ
Enterprise Integration Patterns with ActiveMQ
Ā 
Integration using Apache Camel and Groovy
Integration using Apache Camel and GroovyIntegration using Apache Camel and Groovy
Integration using Apache Camel and Groovy
Ā 
IoT with Apache ActiveMQ, Camel & Spark
IoT with Apache ActiveMQ, Camel & SparkIoT with Apache ActiveMQ, Camel & Spark
IoT with Apache ActiveMQ, Camel & Spark
Ā 
Java Is Not Dead - Bob McWhirter
Java Is Not Dead - Bob McWhirterJava Is Not Dead - Bob McWhirter
Java Is Not Dead - Bob McWhirter
Ā 

Similar to Apache ActiveMQ and Apache Camel

Jms session (1)
Jms session (1)Jms session (1)
Jms session (1)
Marwa Dosoky
Ā 
Indianapolis mule soft_meetup_12_june_2021
Indianapolis mule soft_meetup_12_june_2021Indianapolis mule soft_meetup_12_june_2021
Indianapolis mule soft_meetup_12_june_2021
ikram_ahamed
Ā 
Designing Distributed Systems
Designing Distributed SystemsDesigning Distributed Systems
Designing Distributed Systems
Dhananjay Singh
Ā 
1. Overview of Distributed Systems
1. Overview of Distributed Systems1. Overview of Distributed Systems
1. Overview of Distributed Systems
Daminda Herath
Ā 
Java message service
Java message serviceJava message service
Java message service
Veeramani S
Ā 
Test DB user
Test DB userTest DB user
Test DB user
techweb08
Ā 
test validation
test validationtest validation
test validation
techweb08
Ā 

Similar to Apache ActiveMQ and Apache Camel (20)

Jms session (1)
Jms session (1)Jms session (1)
Jms session (1)
Ā 
JMS
JMSJMS
JMS
Ā 
Enterprise messaging with jms
Enterprise messaging with jmsEnterprise messaging with jms
Enterprise messaging with jms
Ā 
Indianapolis mule soft_meetup_12_june_2021
Indianapolis mule soft_meetup_12_june_2021Indianapolis mule soft_meetup_12_june_2021
Indianapolis mule soft_meetup_12_june_2021
Ā 
Messaging Frameworks using JMS
Messaging Frameworks using JMS Messaging Frameworks using JMS
Messaging Frameworks using JMS
Ā 
Designing Distributed Systems
Designing Distributed SystemsDesigning Distributed Systems
Designing Distributed Systems
Ā 
Design Patterns - Distributed Publisher-Subscriber Network
Design Patterns - Distributed Publisher-Subscriber NetworkDesign Patterns - Distributed Publisher-Subscriber Network
Design Patterns - Distributed Publisher-Subscriber Network
Ā 
1. Overview of Distributed Systems
1. Overview of Distributed Systems1. Overview of Distributed Systems
1. Overview of Distributed Systems
Ā 
Message Queue (MQ) Testing
Message Queue (MQ) TestingMessage Queue (MQ) Testing
Message Queue (MQ) Testing
Ā 
Message Queue (MQ) Testing
Message Queue (MQ) TestingMessage Queue (MQ) Testing
Message Queue (MQ) Testing
Ā 
Synchronous and asynchronous software communication components
Synchronous and asynchronous software communication componentsSynchronous and asynchronous software communication components
Synchronous and asynchronous software communication components
Ā 
Java message service
Java message serviceJava message service
Java message service
Ā 
ActiveMQ interview Questions and Answers
ActiveMQ interview Questions and AnswersActiveMQ interview Questions and Answers
ActiveMQ interview Questions and Answers
Ā 
Integration Patterns With Spring integration
Integration Patterns With Spring integrationIntegration Patterns With Spring integration
Integration Patterns With Spring integration
Ā 
Test DB user
Test DB userTest DB user
Test DB user
Ā 
test validation
test validationtest validation
test validation
Ā 
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...
Ā 
#7 (Java Message Service)
#7 (Java Message Service)#7 (Java Message Service)
#7 (Java Message Service)
Ā 
Jms
JmsJms
Jms
Ā 
Jms intro
Jms introJms intro
Jms intro
Ā 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(ā˜Žļø+971_581248768%)**%*]'#abortion pills for sale in dubai@
Ā 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
Christopher Logan Kennedy
Ā 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
Ā 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
Ā 

Recently uploaded (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
Ā 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Ā 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
Ā 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Ā 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
Ā 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
Ā 
Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot Model
Ā 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Ā 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Ā 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
Ā 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
Ā 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
Ā 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
Ā 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
Ā 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Ā 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
Ā 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Ā 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Ā 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Ā 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Ā 

Apache ActiveMQ and Apache Camel

  • 2. Contents 1. Introduction 2. About JMS 3. Messaging Domains 4. Why ActiveMQ? 5. Benefits
  • 3. Introduction ā— ActiveMQ is used in enterprise service bus implementations such as Apache ServiceMix and Mule. ā— Apache ActiveMQ is a message broker which fully implements the Java Messaging Service API. It can be used by programs written Java,C/C++,.NET,PHP etc.
  • 4. JMS (Java Messaging Service) The Java Message Service (JMS) API is a Java Message Oriented Middleware (MOM) API for sending messages between two or more clients. It is a messaging standard that allows application components based on the Java Enterprise Edition (Java EE) to create, send, receive, and read messages. An application can communicate with any number of applications using JMS.This communication is loosely coupled. Instead, those applications are communicated by connecting to a common destination. An application can send messages to the destination and can take messages from the same destination.The concept is shown below as a schematic.This technology is too simple and it can be easily integrated with existing applications so that those applications can communicate each other.
  • 5. Destination Type Description Topic In JMS a Topic implements publish and subscribe semantics. When you publish a message it goes to all the subscribers who are interested - so zero to many subscribers will receive a copy of the message. Only subscribers who had an active subscription at the time the broker receives the message will get a copy of the message. Queue A JMS Queue implements load balancer semantics. A single message will be received by exactly one consumer. If there are no consumers available at the time the message is sent it will be kept until a consumer is available that can process the message. If a consumer receives a message and does not acknowledge it before closing then the message will be redelivered to another consumer. A queue can have many consumers with messages load balanced across the available consumers.
  • 6. JMS Sessions A session is a single-threaded context for producing and consuming messages. We use sessions to create the following: ā— Message producers ā— Message consumers ā— Messages ā— Destination When a client creates a JMS session it must specify the mode in which the Session will acknowledge the messages that it receives and dispatches. The modes supported are summarized in the table below.
  • 7. Acknowledge Mode Description AUTO_ACKNOWL EDGE With this acknowledgement mode, the session automatically acknowledges a client's receipt of a message either when the session has successfully returned from a call to receive or when the message listener the session has called to process the message successfully returns. CLIENT_ACKNOW LEDGE With this acknowledgement mode, the client acknowledges a consumed message by calling the message's acknowledge method. Acknowledging a consumed message acknowledges all messages that the session has consumed. When client acknowledgement mode is used, a client may build up a large number of unacknowledged messages while attempting to process them. A JMS provider should provide administrators with a way to limit client overrun so that clients are not driven to resource exhaustion and ensuing failure when some resource they are using is temporarily blocked. DUPS_OK_ACKN OWLEDGE This acknowledgement mode instructs the session to lazily acknowledge the delivery of messages. This is likely to result in the delivery of some duplicate messages if the JMS provider fails, so it should only be used by consumers that can tolerate duplicate messages. Use of this mode can reduce session overhead by minimizing the work the session does to prevent duplicates. SESSION_TRANS ACTED Session is Transacted and the acknowledge of messages is handled internally. INDIVIDUAL_ACK NOWLEDGE Acknowledges are applied to a single message only. Unlike CLIENT_ACKNOWLEDGE where the acknowledgement applies to all messages received up to that point for the entire session, this mode applied only to a single message allowing the client to be more selective about which messages are acknowledged.
  • 8. Messaging Domains JMS API supports Point-to-Point and Publish-Subscribe approaches. Point-to-Point Approach : The point to point approach consists of a sender , a receiver and a queue.The sender addresses a message to the queue, and the receiving clients extract messages from the queues established to hold their messages. The queue keeps the message till a receiving client receives it or till the message expires. While any number of producers can send messages to the queue, each message is guaranteed to be delivered, and consumed by one consumer.
  • 9. Publish/Subscribe Approach : The publish/subscribe model supports publishing messages to a particular message topic. Subscribers may register interest in receiving messages on a particular message topic. In this model, neither the publisher nor the subscriber knows about each other. A good analogy for this is an anonymous bulletin board. ā— Zero or more consumers will receive the message. ā— There is a timing dependency between publishers and subscribers. The publisher has to create a message topic for clients to subscribe. The subscriber has to remain continuously active to receive messages, unless it has established a durable subscription. In that case, messages published while the subscriber is not connected will be redistributed whenever it reconnects.
  • 10. A JMS message has 3 parts a)header :- The header contains meta-information about the messageā€” who sent it, where itā€™s going, and so on. b)body :- As the name suggests it is the body of messages. JMS API allows five types of message bodies. 1. TextMessage :- Body contains String data 2. ByteMessage :- Body contains byte data 3. MapMessage :- Body contains data in key/value pair 4. StreamMessage :-Body contains a stream of primitive values 5. ObjectMessage : ā€“ Body contains an object 6. Message :- Nothing in body. Only header and properties. c)properties :- Additional properties other than header.
  • 11. Why Messaging as Communication Style? ā— File Transfer and Shared Database enable applications to share their data but not their functionality. ā— Remote Procedure Invocation enables applications to share functionality, but it tightly couples them as well. Often the challenge of integration is about making collaboration between separate systems as timely as possible, without coupling systems together in such a way that they become unreliable either in terms of application execution or application development. ā— The data transfer should be asynchronous so that the sender does not need to wait on the receiver, especially when retry is necessary. ā— Use Messaging to transfer packets of data frequently, immediately, reliably, and asynchronously, using customizable formats.
  • 12. Why ActiveMQ? Imagine you need to communicate with two or more systems. A common approach these days will be web services which is fine if you need an answers right away. However: web services can be down and not available - what do you do then? Putting your message into a message queue (which has a component on your machine/server, too) typically will work in this scenario - your message just doesn't get delivered and thus processed right now - but it will later on, when the other side of the service comes back online. The Message Queue receives the message, places it in the proper queue, and waits for the application to retrieve the message when ready.
  • 13. Connect an application to a messaging channel using a Message Endpoint, a client of the messaging system that the application can then use to send or receive Messages.We need a message endpoint to connect the system explicitly to the integration solution. The endpoint can be a special piece of code or a channel adapter provided by an integration software vendor. For example, one data format may store the customer name in two fields, called FIRST_NAME and LAST_NAME, while the other system may use a single field called Customer_Name. Likewise, one system may support multiple customer addresses while the other system only supports a single address. Because the internal data format of an application can often not be changed the middleware needs to provide some mechanism to convert one applicationā€™s data format in the otherā€™s. We call this step translation.
  • 14. So far we can send data from one system to another and accommodate differences in data formats. What happens if we integrate more than two systems? Where does the data have to be moved? We could expect each application to specify the target system(s) for the data it is sending over the channel. For example, if the customer address changes in the customer care system we could make that system responsible for sending the data to all other systems that store copies of the customer address. As the number of systems increases this becomes very tedious and requires the sending system to have knowledge about all other systems. Every time a new system is added, the customer care system would have to be adjusted to the new environment. Things would be a lot easier of the middleware could take care of sending messages to the correct places. This is the role of a routing component such as a message broker. Integration solutions can quickly become complex because they deal with multiple applications, data formats, channels, routing and transformation. All these elements may be spread across multiple operating platforms and geographic locations. In order to have any idea what is going on inside the system we need a systems management function. This subsystem monitors the flow of data, makes sure that all applications and components are available and reports error conditions to a central location.
  • 15. When a standard message is sent to a queue from a producer, it is sent to the broker, which persists it in its message store. By default this is in KahaDB, but it can configured to be stored in memory, which buys performance at the cost of reliability. Once the broker has confirmation that the message has been persisted in the journal (the terms journal and message store are often used interchangeably), it responds with an acknowledgement back to the producer. The thread sending the message from the producer is blocked at this time.
  • 16. On the consumption side, when a message listener is registered or a call to receive() is made, the broker creates a subscription to that queue. Messages are fetched from the message store and passed to the consumer; itā€™s usually done in batches, and the fetching is a lot more complex than simply read from disk, but thatā€™s the general idea. With the default behaviour, assuming the Session.AUTO_ACKNOWLEDGE is being used, the consumer will acknowledge that the message has been received before processing it. On receiving the acknowledgement, the broker updates the message store marking that message as consumed, or just deletes it (this depends on the persistence mechanism).
  • 17.
  • 18. This figure also illustrates two important messaging concepts: 1. Send and forget ā€”In step 2, the sending application sends the message to the message channel. Once that send is complete, the sender can go on to other work while the messaging system transmits the message in the background. The sender can be confident that the receiver will eventually receive the message and does not have to wait until that happens. 2. Store and forward ā€”In step 2, when the sending application sends the message to the message channel, the messaging system stores the message on the senderā€™s computer, either in memory or on disk. In step 3, the messaging system delivers the message by forwarding it from the senderā€™s computer to the receiverā€™s computer, and then stores the message once again on the receiverā€™s computer. This store-and- forward process may be repeated many times as the message is moved from one computer to another until it reaches the receiverā€™s computer.
  • 19. Benefits : Using messaging as an integration or communication style leads to many benefits such as: ā— Allowing applications built with different languages and on different operating systems to integrate with each other ā— Location transparency ā€“ client applications donā€™t need to know where the service applications are located ā— Reliable communication ā€“ the producers/consumers of messages donā€™t have to be available at the same time, or certain segments along the route of the message can go down and come back up without impacting the message getting to the service/consumer ā— Scaling ā€“ can scale horizontally by adding more services that can handle the messages if too many messages are arriving ā— Asynchronous communication ā€“ a client can fire a message and continue other processing instead of blocking until the service has sent a response; it can handle the response message only when the message is ready ā— Reduced coupling ā€“ the assumptions made by the clients and services are greatly reduced as a result of the previous 5 benefits. A service can change details about itself, including its location, protocol, and availability, without affecting or disrupting the client.
  • 21. Contents 1) Introduction 2) About Camel 3) Messaging Models 4) Example 5) Architecture
  • 22.
  • 23. Introduction ā— Apache Camel ā€œa powerful open source integration framework based on known Enterprise Integration Patterns with powerful Bean Integrationā€. ā— Camel is a mediation and routing engine that lets you implement EIPā€™s. It uses a simple URI notation to identify the different transport and messaging models. ā— Camel is open-source integration framework which allows you to build routes for integration scenario's quickly and efficiently. You can deploy these routes directly on ServiceMix by deploying the plain Spring XML route or by packaging the route in an OSGi bundle. ā— The best thing about Camel is that it can be embedded into your current java application to implement integrations. On a larger scale Camel is part of Apache ServiceMix ESB. ā— The Camel project was started in early 2007.
  • 24. About Camel ā— Building complex systems from scratch is a very costly endeavor, and one thatā€™s almost never successful. Apache Camel is such an integration framework that provides simple, manageable abstractions for the complex systems youā€™re integrating and the ā€œglueā€ for plugging them together seamlessly. ā— Camelā€™s most important features: message routing. At the core of the Camel framework is a routing engine, or more precisely a routing engine builder. It allows you to define your own routing rules, decide from which sources to accept messages, and determine how to process and send those messages to other destinations. For example: JMS -> JSON, HTTP -> JMS or funneling FTP -> JMS, HTTP -> JMS, JSON -> JMS
  • 25. ā— Camel has two main ways of defining routing rules: the Java-based domain specific language (DSL) and the Spring XML configuration format. ā— One of the fundamental principles of Camel is that it makes no assumptions about the type of data you need to process. This 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. ā— Camel isnā€™t an enterprise service bus(ESB), although some call Camel a lightweight ESB because of its support for routing, transformation, monitoring, orchestration, and so forth. Camel doesnā€™t have a container or a reliable message bus, but it can be deployed in one, such as Open-ESB or the ServiceMix. For that reason, we prefer to call Camel an integration framework rather than an ESB. Camel was designed not to be a server or ESB but instead to be embedded in whatever platform you choose.
  • 26. Camelā€™s message model In Camel, there are two abstractions for modeling messages, ā–  org.apache.camel.Message ā€”The fundamental entity containing the data being carried and routed in Camel. ā€”The Message interface provides an abstraction for a single message, such as a request, reply or exception message. In Camel terminology, the request, reply and exception messages are called in, out and fault messages. ā–  org.apache.camel.Exchange ā€”The Camel abstraction for an exchange of messages. This exchange of messages has an ā€œinā€ message and as a reply, an ā€œoutā€ message. ā€”The Exchange interface provides an abstraction for an exchange of messages, that is, a request message and its corresponding reply or exception message.
  • 27. Example on Routing Files: Suppose you need to read files from one directory (data/inbox), process them in some way, and write the result to another directory (data/outbox). For simplicity, youā€™ll skip the processing, so your output will be merely a copy of the original file. Below figure illustrates this process. It looks pretty simple, right? Hereā€™s a possible solution using pure Java (with no Camel) but it still results in 34 lines of code. You have to use low-level file APIs and ensure that resources get closed properly, a task that can easily go wrong. But if an integration framework like Apache Camel is used, we can create a file-polling route in just one line of Java code
  • 29. CamelContext A CamelContext object represents the Camel runtime system. CamelContext is the heart of Camel its where all the routes, endpoints, components, etc. is registered. You typically have one CamelContext object in an application. A typical application executes the following steps. ā— Create a CamelContext object. ā— Add endpoints ā€“ and possibly Components, to the CamelContext object. ā— Add routes to the CamelContext object to connect the endpoints. ā— Invoke the start() operation on the CamelContext object. This starts Camel-internal threads that are used to process the sending, receiving and processing of messages in the endpoints. ā— Eventually invoke the stop() operation on the CamelContext object. Doing this gracefully stops all the endpoints and Camel-internal threads.
  • 30. Components Component is confusing terminology; EndpointFactory would have been more appropriate because a Component is a factory for creating Endpoint instances. Processor The Processor interface represents a class that processes a message. Notice that the parameter to the process() method is an Exchange rather than a Message. RouteBuilders A route is the step-by-step movement of a Message from an input queue, through arbitrary types of decision making (such as filters and routers) to a destination queue (if any). A DSL wires Endpoints and Processors together to form routes. Camel provides two ways for an application developer to specify routes. One way is to specify route information in an XML file. A discussion of that approach is outside the scope of this document. The other way is through what Camel calls a Java DSL (domain-specific language).
  • 31. Here are some examples of the DSL using different languages and staying functionally equivalent: ī€Š 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 real code, and they show how easily you can route files from a folder to a JMS queue.
  • 32. Content Based Router The Content Based Router from the EIP patterns allows you to route messages to the correct destination based on the contents of the message exchanges. The Content-Based Router examines the message content and routes the message onto a different channel based on data contained in the message.
  • 33. Message Filter The Message Filter from the EIP patterns allows you to filter messages. The Message Filter has only a single output channel. If the message content matches the criteria specified by the Message Filter, the message is routed to the output channel. If the message content does not match the criteria, the message is discarded.
  • 34.