简介

Apache ActiveMQ is an open-source message broker written in Java. It supports several cross-language clients and protocols.

The Apache ActiveMQ message broker is a fast, reliable, scalable, and totally integrated open source messaging platform for handling lots of messages (ingest) or lots of consumers (dispatch). It uses memory as the storage format; it can be configured to store data persistently on a disk if necessary. The initial startup time can be slow due to the fact that ActiveMQ will load all historical information into memory. However, after the first startup period, which could take up to several minutes depending on how much history you have stored in your queues and other configuration settings, performance starts to scale well up until a point when we consider other factors such as system resources.

Based on its origins as an experience of just moving from an in-house messaging solution to a commercial product, ActiveMQ can be considered as one of those products that have been constantly developed and improved, offering extremely high quality and solid stability.

ActiveMQ provides both a simple embedded broker and a fully deployed, highly available enterprise solution. Its most important features and strengths are high availability and failover (a setup with one broker can survive up to 99.999% of message loss), support for many ways of connecting clients (including web consoles, command-line tools, and libraries, JMS client libraries, etc.), clustering across physical boundaries, load balancing through multiple internal queues per topic, flexible configuration such as persistent or non-persistent messages according to the need, the persistence of data by file or database, security implementation based on JAAS authentication model which also supports LDAP implementation.

ActiveMQ is truly the preferred messaging solution for Java developers, infrastructure architects, and system integrators. It can be used in both small deployments (in which case you will probably use the embedded broker) or big enterprise solutions (which require clustering and failover).

Depending on your needs, ActiveMQ can be easily scaled out to real high availability scenarios with full load balancing across all brokers, including dynamic addition of new nodes when existing ones go down; stateful failover with automatic re-sync and potential data loss (which is always possible), fully supported by ActiveMQ itself: just another two nodes that need to be configured into a cluster for high availability.

Apache ActiveMQ is cross-platform and runs in a Java Virtual Machine (JVM). You could use ActiveMQ on either Linux, Windows, or OS X.

安装

Ubuntu系统

环境配置

  • 规格:4C8G,100G数据盘
  • 系统:20.04.3 LTS (GNU/Linux 5.4.0-107-generic x86_64)
  • PostgreSQL版本:PostgreSQL 9.5.25

Pre-Installation Requirements

Hardware:

  • 60 MB of free disk space for the ActiveMQ binary distribution.
  • 200 MB of free disk space for the ActiveMQ source or developer’s distributions.

Operating Systems:

  • Windows: Windows XP SP2, Windows 2000.
  • Unix: Ubuntu Linux, Powerdog Linux, MacOS, AIX, HP-UX, Solaris, or any Unix platform that supports Java.

Environment:

  • Java Developer Kit (JDK) 1.7.x or greater for deployment and 1.7.x (Java 7) for compiling/building.
  • The JAVA_HOME environment variable must be set to the directory where the JDK is installed, e.g., c:\Program Files\jdk.1.7.0_xx_xx.
  • Maven 3.0 or greater (required when installing source or developer’s releases).
  • JARs that will be used must be added to the classpath.

安装流程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 安装基础依赖包
sudo apt-get update
sudo apt install openjdk-8-jdk

# 下载资源包
sudo wget http://www.apache.org/dist/activemq/5.16.4/apache-activemq-5.16.4-bin.tar.gz

# 解压资源包
sudo tar zxvf apache-activemq-*gz -C /opt/

# 创建服务用户
sudo addgroup --quiet --system activemq
sudo adduser --quiet --system --ingroup activemq --no-create-home --disabled-password activemq
sudo chown -R activemq:activemq /opt/apache-activemq*

# 创建systemctl服务
ACTIVEMQ_DIR=$(cd /opt/apache-activemq* && pwd)
cat > /usr/lib/systemd/system/activemq.service << EOF
[Unit]
Description=Apache ActiveMQ
After=network.target

[Service]
Type=forking
User=activemq
Group=activemq
ExecStart=${ACTIVEMQ_DIR}/bin/activemq start
ExecStop=${ACTIVEMQ_DIR}/bin/activemq stop
ExecRestart=${ACTIVEMQ_DIR}/bin/activemq stop : ${ACTIVEMQ_DIR}/bin/activemq start

[Install]
WantedBy=multi-user.target
EOF

# 启动服务
sudo systemctl start activemq
sudo systemctl status activemq

参考文档