Introduction to Apache ActiveMQ
08. 22. 2019
Wooyoung Choi
wychoi@redwood.snu.ac.kr
Real-Time Operating Systems Laboratory,
Seoul National University
2
Contents
I. Introduction
II. Java Message Service (JMS)
III. Message Oriented Middleware (MOM)
IV. ActiveMQ
V. Conclusion
Introduction to Apache ActiveMQ
3
The Goal of the Presentation
 To get a clear understanding of Apache ActiveMQ.
 ActiveMQ is
① Java Message Service (JMS) 1.1 compliant.
• ActiveMQ is implemented with JMS.
② Message Oriented Middleware (MOM) product that
provides asynchronous messaging.
I. Introduction
4
Motivation
 As a replacement for Remote Procedure Call (RPC).
RPC-synchronous calls have a limited scalability.
Backed up requests slow down the whole system.
Solution : Use asynchronous call to increase scalability.
 To achieve high availability and scalability.
The ability to continue functioning after failure of one or more
servers.
Solution : Migrate from one server to another using brokers in
event of server failure.
I. Introduction
Client server
RPC
5
Contents
I. Introduction
II. Java Message Service (JMS)
III. Message Oriented Middleware (MOM)
IV. ActiveMQ
V. Conclusion
Introduction to Apache ActiveMQ
6
Overview
 What is Java Message Service (JMS)?
JMS is a Message Oriented Middleware (MOM).
Loosely coupled communication.
Asynchronous messaging.
Reliable delivery which means high availability.
II. Java Message Service (JMS)
JMS Interface
7
Goals of JMS
 When to use JMS?
When the provider do not want the components to depend
on other components’ interfaces.
When the provider wants the application to run whether all
components are running or not.
When the provider wants a component to operate without
receiving an immediate response.
II. Java Message Service (JMS)
8
JMS Messaging Models (1)
 Point to Point
Each message has only one receiver.
Message is sent to a queue.
There is no dependency between producer and receiver.
• Producer and receiver are independent to each other.
 Publish-Subscribe
II. Java Message Service (JMS)
9
JMS Messaging Models (2)
 Point to Point
 Publish-Subscribe
Each message can have multiple receivers.
Messages are sent to Topic.
It is used when multiple receivers need to receive the same
messages.
II. Java Message Service (JMS)
10
JMS Provider: ActiveMQ
II. Java Message Service (JMS)
 Java Message Service (JMS) lets user to send
messages from one program to another.
 However, it doesn’t use direct connection.
Instead the message is sent to a JMS provider, such as
ActiveMQ, and put there in a queue.
 Summary: ActiveMQ is a JMS provider and it is
implemented with JMS.
11
Contents
I. Introduction
II. Java Message Service (JMS)
III. Message Oriented Middleware (MOM)
IV. ActiveMQ
V. Conclusion
Introduction to Apache ActiveMQ
12
Overview
 Definition
The layer, which allows programs to communicate by
sending and receiving messages.
 Objective
Message Oriented Middleware allows programmers to
integrate many heterogeneous components for software
systems.
III. Message Oriented Middleware (MOM)
13
Features of MOM: Message Queue
 MOM is implemented as a form of Message Queue.
 Message Queue’s features are
Scalability
① Broker clusters
② Multiple destinations for a publishers or subscribers.
Availability
① Broker clusters
② Master/Slave
Performance
① Memory resource management
III. Message Oriented Middleware (MOM)
14
Contents
I. Introduction
II. Java Message Service (JMS)
III. Message Oriented Middleware (MOM)
IV. ActiveMQ
V. Conclusion
Introduction to Apache ActiveMQ
15
Overview
 What is ActiveMQ?
Message Oriented Middleware (MOM)
• The layer that allows software components to interact with one
other.
ActiveMQ is the most popular open source messaging and
JMS provider developed by Apache.
IV. ActiveMQ
JMS
Compliant
16
Features
 Supports a variety of Cross Language Clients from
Java, C, C++, C#, Python, PHP.
 Designed for high performance clustering.
Network of brokers
 Supports very fast and stable persistence
Master/Slave
IV. ActiveMQ
17
Clustered Brokers improve scalability
 Networks of Brokers
It creates a cluster composed of multiple ActiveMQ
instances.
It allows brokers to communicate each other.
Consequence : It improves scalability.
IV. ActiveMQ
18
Master/Slave improves persistence (1)
 Shared-Nothing Master/Slave structure
Master and Slave have their own message storage.
Slave is connected to the master broker.
All message commands are replicated from the master.
Slave broker takes over Master broker’s task when Master
broker falls down.
IV. ActiveMQ
19
Master/Slave improves persistence (2)
 Shared-Storage Master/Slave structure
Allows many brokers to share the storage mechanism.
Only one broker can be live at any given time.
Master has a file lock and another slave takes over the lock
when the master falls down.
IV. ActiveMQ
20
Hello World Example using ActiveMQ
(1)
1. Connect Producer to broker URL (tcp://localhost:61616).
2. Send a small text message saying “Hello World”.
3. The text message is enqueued in broker URL.
4. Connect Receiver to broker URL (tcp://localhost:61616).
5. Receiver receives the text message from the queue at
broker URL.
6. The message is dequeued.
IV. ActiveMQ
21
Hello World Example using ActiveMQ
(2)
1. Connect Producer to broker URL (tcp://localhost:61616).
2. Send a small text message saying “Hello World”.
IV. ActiveMQ
①
②
22
Hello World Example using ActiveMQ
(3)
3. The text message is enqueued in broker URL.
IV. ActiveMQ
③
23
Hello World Example using ActiveMQ
(4)
4. Connect Receiver to broker URL (tcp://localhost:61616).
5. Receiver receives the text message from the queue at
broker URL.
IV. ActiveMQ
④
⑤
24
Hello World Example using ActiveMQ
(5)
6. The message is dequeued.
IV. ActiveMQ
⑥
25
Contents
I. Introduction
II. Java Message Service (JMS)
III. Message Oriented Middleware (MOM)
IV. ActiveMQ
V. Conclusion
Introduction to Apache ActiveMQ
26
Summary
 Apache ActiveMQ is
Java Message Service provider
Message Oriented Middleware
with high scalability and reliability
 Clustered Brokers
Improve scalability.
Guarantee availability.
 Master/Slave Brokers
Guarantee fast and stable persistence when one falls down.
V. Conclusion

19 08-22 introduction to activeMQ

  • 1.
    Introduction to ApacheActiveMQ 08. 22. 2019 Wooyoung Choi wychoi@redwood.snu.ac.kr Real-Time Operating Systems Laboratory, Seoul National University
  • 2.
    2 Contents I. Introduction II. JavaMessage Service (JMS) III. Message Oriented Middleware (MOM) IV. ActiveMQ V. Conclusion Introduction to Apache ActiveMQ
  • 3.
    3 The Goal ofthe Presentation  To get a clear understanding of Apache ActiveMQ.  ActiveMQ is ① Java Message Service (JMS) 1.1 compliant. • ActiveMQ is implemented with JMS. ② Message Oriented Middleware (MOM) product that provides asynchronous messaging. I. Introduction
  • 4.
    4 Motivation  As areplacement for Remote Procedure Call (RPC). RPC-synchronous calls have a limited scalability. Backed up requests slow down the whole system. Solution : Use asynchronous call to increase scalability.  To achieve high availability and scalability. The ability to continue functioning after failure of one or more servers. Solution : Migrate from one server to another using brokers in event of server failure. I. Introduction Client server RPC
  • 5.
    5 Contents I. Introduction II. JavaMessage Service (JMS) III. Message Oriented Middleware (MOM) IV. ActiveMQ V. Conclusion Introduction to Apache ActiveMQ
  • 6.
    6 Overview  What isJava Message Service (JMS)? JMS is a Message Oriented Middleware (MOM). Loosely coupled communication. Asynchronous messaging. Reliable delivery which means high availability. II. Java Message Service (JMS) JMS Interface
  • 7.
    7 Goals of JMS When to use JMS? When the provider do not want the components to depend on other components’ interfaces. When the provider wants the application to run whether all components are running or not. When the provider wants a component to operate without receiving an immediate response. II. Java Message Service (JMS)
  • 8.
    8 JMS Messaging Models(1)  Point to Point Each message has only one receiver. Message is sent to a queue. There is no dependency between producer and receiver. • Producer and receiver are independent to each other.  Publish-Subscribe II. Java Message Service (JMS)
  • 9.
    9 JMS Messaging Models(2)  Point to Point  Publish-Subscribe Each message can have multiple receivers. Messages are sent to Topic. It is used when multiple receivers need to receive the same messages. II. Java Message Service (JMS)
  • 10.
    10 JMS Provider: ActiveMQ II.Java Message Service (JMS)  Java Message Service (JMS) lets user to send messages from one program to another.  However, it doesn’t use direct connection. Instead the message is sent to a JMS provider, such as ActiveMQ, and put there in a queue.  Summary: ActiveMQ is a JMS provider and it is implemented with JMS.
  • 11.
    11 Contents I. Introduction II. JavaMessage Service (JMS) III. Message Oriented Middleware (MOM) IV. ActiveMQ V. Conclusion Introduction to Apache ActiveMQ
  • 12.
    12 Overview  Definition The layer,which allows programs to communicate by sending and receiving messages.  Objective Message Oriented Middleware allows programmers to integrate many heterogeneous components for software systems. III. Message Oriented Middleware (MOM)
  • 13.
    13 Features of MOM:Message Queue  MOM is implemented as a form of Message Queue.  Message Queue’s features are Scalability ① Broker clusters ② Multiple destinations for a publishers or subscribers. Availability ① Broker clusters ② Master/Slave Performance ① Memory resource management III. Message Oriented Middleware (MOM)
  • 14.
    14 Contents I. Introduction II. JavaMessage Service (JMS) III. Message Oriented Middleware (MOM) IV. ActiveMQ V. Conclusion Introduction to Apache ActiveMQ
  • 15.
    15 Overview  What isActiveMQ? Message Oriented Middleware (MOM) • The layer that allows software components to interact with one other. ActiveMQ is the most popular open source messaging and JMS provider developed by Apache. IV. ActiveMQ JMS Compliant
  • 16.
    16 Features  Supports avariety of Cross Language Clients from Java, C, C++, C#, Python, PHP.  Designed for high performance clustering. Network of brokers  Supports very fast and stable persistence Master/Slave IV. ActiveMQ
  • 17.
    17 Clustered Brokers improvescalability  Networks of Brokers It creates a cluster composed of multiple ActiveMQ instances. It allows brokers to communicate each other. Consequence : It improves scalability. IV. ActiveMQ
  • 18.
    18 Master/Slave improves persistence(1)  Shared-Nothing Master/Slave structure Master and Slave have their own message storage. Slave is connected to the master broker. All message commands are replicated from the master. Slave broker takes over Master broker’s task when Master broker falls down. IV. ActiveMQ
  • 19.
    19 Master/Slave improves persistence(2)  Shared-Storage Master/Slave structure Allows many brokers to share the storage mechanism. Only one broker can be live at any given time. Master has a file lock and another slave takes over the lock when the master falls down. IV. ActiveMQ
  • 20.
    20 Hello World Exampleusing ActiveMQ (1) 1. Connect Producer to broker URL (tcp://localhost:61616). 2. Send a small text message saying “Hello World”. 3. The text message is enqueued in broker URL. 4. Connect Receiver to broker URL (tcp://localhost:61616). 5. Receiver receives the text message from the queue at broker URL. 6. The message is dequeued. IV. ActiveMQ
  • 21.
    21 Hello World Exampleusing ActiveMQ (2) 1. Connect Producer to broker URL (tcp://localhost:61616). 2. Send a small text message saying “Hello World”. IV. ActiveMQ ① ②
  • 22.
    22 Hello World Exampleusing ActiveMQ (3) 3. The text message is enqueued in broker URL. IV. ActiveMQ ③
  • 23.
    23 Hello World Exampleusing ActiveMQ (4) 4. Connect Receiver to broker URL (tcp://localhost:61616). 5. Receiver receives the text message from the queue at broker URL. IV. ActiveMQ ④ ⑤
  • 24.
    24 Hello World Exampleusing ActiveMQ (5) 6. The message is dequeued. IV. ActiveMQ ⑥
  • 25.
    25 Contents I. Introduction II. JavaMessage Service (JMS) III. Message Oriented Middleware (MOM) IV. ActiveMQ V. Conclusion Introduction to Apache ActiveMQ
  • 26.
    26 Summary  Apache ActiveMQis Java Message Service provider Message Oriented Middleware with high scalability and reliability  Clustered Brokers Improve scalability. Guarantee availability.  Master/Slave Brokers Guarantee fast and stable persistence when one falls down. V. Conclusion