Apache ActiveMQ is a free and open source messaging and integration pattern server. It is most widely used in enterprise software developement and some of its features are listed below.
- Supports a variety of Cross Language Clients and Protocols from Java, C, C++, C#, Ruby, Perl, Python, PHP
- OpenWire for high performance clients in Java, C, C++, C#
- MQTT v3.1 support allowing for connections in an IoT environment.
- Full support for the Enterprise Integration Patterns both in the JMS client and the Message Broker
- Fully supports JMS 1.1 and J2EE 1.4 with support for transient, persistent, transactional and XA messaging
- Spring Support so that ActiveMQ can be easily embedded into Spring applications and configured using Spring's XML configuration mechanism.
- A CentOS 7 Server
- A root user
- Java 7 or greater
It is highly recommended to update your system and upgrade all available packages before going through the installation process so run below given command it will do the job for you.
yum -y update
Install OpenJDK JRE 8
Once the system is updated you'll have to install OpenJDK JRE 8 because Apache ActiveMQ requires java 7 or greater so let's install java using below given command.
yum install -y java-1.8.0-openjdk
Next check java version and verify the installation result.
You should see following output as result.
[root@Sajid ~]# java -version openjdk version "1.8.0_121" OpenJDK Runtime Environment (build 1.8.0_121-b13) OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)
Next you'll have to setup java home environment variable.
echo "JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")" | sudo tee -a /etc/profile
Installing Apache ActiveMQ
We have installed all the required dependencies now we can proceed to install Apache ActiveMQ so first download the latest stable release of Apache ActiveMQ and to do so run below given command it'll do the job for you.
If in case you don't have wget package already installed on your system then you can install it using
yum -y install wget
Now extract this downloaded file as shown below.
tar -zxvf apache-activemq-5.14.3-bin.tar.gz -C /opt
We recommended for you to create a version-independent soft link pointing to the directory in which current release of Apache ActiveMQ resides. This practice is helpful for future updates.
ln -s /opt/apache-activemq-5.14.3 /opt/activemq
Create a Systemd Unit
You can launch Apache ActiveMQ by running its executable file like shown below.
But we recommend you run Apache ActiveMQ through systemd unit file so first create a systemd unit file.
If in case you don't have nano text editor installed on your system then you can install it using
yum -y install nano and then create a systemd unit file as shown below.
Add the following content to the systemd unit file you can simply copy paste it to the file.
[Unit] Description=activemq message queue After=network.target [Service] ExecStart=/opt/activemq/bin/activemq start ExecStop=/opt/activemq/bin/activemq stop User=root Group=root [Install] WantedBy=multi-user.target
Save the file and exit from the text editor.
Now we can use systemd to easily start, enable and stop the apache activemq services like shown below.
systemctl enable activemq.service
systemctl start activemq.service
systemctl stop activemq.service
Let's start the apache activemq services and we will also have to modify firewalld rules.
systemctl start activemq.service
Next you’ll have to modify firewall rules and if in case you don’t have firewalld services installed on your server then you can install it using
yum -y install firewalld and you can start it using
systemctl start firewalld
Next run these below given command to modify the firewalld rules and allow access to port 8161.
firewall-cmd --zone=public --permanent --add-port=8161/tcp
Web Access of Apache ActiveMQ
Open your favorite web browser and visit http://yourserverIP:8161/admin and you'll see a login page use admin as both username and password for login after successfully login you'll see a web page like this.
The username and password can be configured in the
Monitoring ActiveMQ With ActiveMQ Monitor (AMon)
AMon is a highly configurable and extensible enterprise-class monitoring framework for the Apache ActiveMQ message broker. AMon gives systems administrators and managers the ability to monitor the overall health and performance of the ActiveMQ message broker. Some benefits of AMon are listed below.
- SNMP Support: Allows you to monitor ActiveMQ via the SNMPv2 protocol.
- Quick and Customizable: Quickly develop custom monitoring agents (Monlets) for the ActiveMQ message broker without having to change the core ActiveMQ product.
- Apache Camel: Monlets are deployed as Camel Routes and can thus leverage the power of the Camel integration framework.
- Metrics and Performance Data: Monlets can be customized to provide performance data that can be used by operators for observation of system performance.
- Logging: AMon provides the ability to easily transform selected broker log messages into SNMP notifications.
- JVM Monitoring: AMon allows Monlets to monitor conditions associated with the broker's hosting Java Virtual Machine (JVM).
To install ActiveMQ Monitor first we will have to download the gzip archive file copy it to your machine.
Next extract the files from the archive file that we have just downloaded into the ACTIVEMQ_HOME directory.
After that obtain a permanent lifetime license and place the file in the ACTIVEMQ_HOME/conf directory using any text editor.
In this tutorial you have learned how to install Apache ActiveMQ on your CentOS 7 server and you also got to know about how to monitor ActiveMQ using AMon.