Introduction to Apache ActiveMQ Artemis

lanabe 4,887 views 24 slides Sep 29, 2017
Slide 1
Slide 1 of 24
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24

About This Presentation

第二十回 #渋谷java の発表資料です。
https://shibuya-java.connpass.com/event/65433/


Slide Content

Introduction to Apache ActiveMQ Artemis
田邊 義真(たなべ よしまさ)


第二十回 #渋谷jav a

@emaggame

morec.at

このドキュメントのリポジトリ
1

Agenda
Why Messaging
Apache ActiveMQ Artemis
Getting Started
2

Why Messaging
Asynchronous Messaging Passing
Decoupling between Producers and Consumers
Routing by Broker
e.g. Selector, Security and Flow Control
3

Messaging Components
4

Orchestration vs Choreography
5

Broker Implementations
: Java
: Scala, Java
: Erlang

Apache ActiveMQ Artemis

Apache Kafka
RabbitMQ
6

Apache ActiveMQ Artemis
High Performance
Flexible Clustering & HA
Multi Protocols Support
7

High Performance
Evaluating persistent, replicated message queues - SoftwareMill
8

High Performance
Journal Implementations: Message Persistence
Java NIO
Linux Asynchronous IO
Memory mapped
Apache ActiveMQ Artemis File Journal (Default) - Apache ActiveMQ Artemis User Manual
9

Flexible Clustering & HA
Clustering
TCP / UDP /
Server-Side Message Load Balancing
Client-Side Load balancing
Message Redistribution
High Availability
Replication
Shared Store
JGroups
10

Clustering
Clusters - Apache ActiveMQ Artemis User Manual
11

High Availability
Replication
High Availability and Failover - Apache ActiveMQ Artemis User Manual
12

High Availability
Shared Store
High Availability and Failover - Apache ActiveMQ Artemis User Manual
13

Multi Protocols Support
AMQP
OpenWire
MQTT
STOMP
HornetQ
HTTP(Tunnel / REST Interface)
14

Getting Started
1. Create a Broker
2. Run the Broker
3. Run Clients(Publisher / Consumer)
15

Create a Broker
$ ${ARTEMIS_HOME}/bin/artemis create mybroker
[... some interactions e.g. username, password ...]
done! Your system can make 0.5 writes per millisecond, your journ
You can now start the broker by executing:
"/path/to/artemis/mybroker/bin/artemis" run
Or you can run the broker in the background using:
"/path/to/artemis/mybroker/bin/artemis-service" start
16

Setup the Broker
Edit mybroker/etc/broker.xml.
Apache ActiveMQ Artemis User Manual
<acceptors>
<acceptor name="artemis">
tcp://0.0.0.0:61616?protocols=CORE,AMQP,STOMP,...
</acceptor>
</acceptors>
<addresses>
<address name="exampleQueue">
<anycast>
<queue name="exampleQueue"/>
</anycast>
</address>
</addresses>
Configuring the Transport
Apache ActiveMQ Artemis Addressing and Queues
17

Run the Broker
$ cd mybroker
$ bin/artemis run
_ _ _
/ \ ____| |_ ___ __ __(_) _____
/ _ \| _ \ __|/ _ \ \/ | |/ __/
/ ___ \ | \/ |_/ __/ |\/| | |\___ \
/_/ \_\| \__\____|_| |_|_|/___ /
Apache ActiveMQ Artemis 2.3.0
[...]
18

Run Publisher
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionF
import javax.jms.JMSContext;
import javax.jms.Queue;
Queue queue = ActiveMQJMSClient.createQueue( "exampleQueue");
try (ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory
JMSContext context = cf.createContext()) {
context
.createProducer()
.send(queue, "Hello, Artemis!");
}
19

Run Consumer
Queue queue = ActiveMQJMSClient.createQueue( "exampleQueue");
try (ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory
JMSContext context = cf.createContext()) {
String message = context
.createConsumer(queue)
.receiveBody(String.class);
System.out.println( "Received: " + message);
}
Received: Hello, Artemis!
20

REST Interface
Producer
Consumer
$ curl -XPOST -H 'Content-Type: application/json' \
http://localhost:8080/queues/orders/create -d '
{
"order" : "Test Order"
}'
$ curl -XPOST http://localhost:8080/queues/orders/pull-consumers
{
"order" : "Test Order"
}
REST Interface - Apache ActiveMQ Artemis User Manual
21

Management Console
Management Console - Apache ActiveMQ Artemis User Manual
22

Summary
High Performance
Flexible Clustering & HA
Multi Protocols Support
23

Resources
Official
Documents
Examples
https://activemq.apache.org/artemis
https://activemq.apache.org/artemis/docs.html
https://github.com/apache/activemq-
artemis/tree/2.3.0/examples
24