How to Install Apache ActiveMQ on CentOS/RHEL 8
Abstract: you can use the systemctl commands to start. enable and check the status of Apache ActiveMQ service as shown. # systemctl start activemq.serviceSettin
ActiveMQ is a popular, open-source, multi-protocol implementation of message-oriented middleware (MOM) with enterprise features written in Java, used to send messages between two applications, or two components inside an application.
It supports a wide range of Cross-Language Clients from Java, C, C++, C#, Ruby, Perl, Python, PHP, and transport protocols such as OpenWire, STOMP, MQTT, AMQP, REST, and WebSockets.
Read Also: How to Install Apache ActiveMQ on Debian 10
Some of its use cases include transactional messaging, clustering and general-purpose async messaging model, web streaming of data, RESTful API to messaging using HTTP, and much more.
In this article, we will explain to you how to install the latest version of Apache ActiveMQ on CentOS 8 and RHEL 8 Linux distribution.
Installing Apache ActiveMQ on CentOS and RHEL 8To install ActiveMQ, your system must have Java installed on your server. If Java is not installed, you can install it on your system using our How to Install Java on CentOS and RHEL 8 guide.
Once Java is installed, you can proceed further to download the latest version of ActiveMQ or use the following wget command to grab the source package as shown.
# cd /opt # wget https://www.apache.org/dist/activemq/5.16.4/apache-activemq-5.16.4-bin.tar.gz
Now extract the archive file using the tar command and move it into the extracted directory using the cd command as shown.
# tar zxvf apache-activemq-5.16.4-bin.tar.gz # cd apache-activemq-5.16.4
Now your ActiveMQ package should be installed in the /opt directory and you can view its contents using the ls command.
# ls -lActiveMQ Files
From the output above, there are some key directories you need to take note of, they include the following:
- bin – stores the binary file plus other related files.
- conf – contains the configuration files: the main configuration file activemq.xml, written in XML format.
- data – stores the PID file as well as log files.
- docs – contains documentation files.
- lib – stores library files.
- webapps – contains the web interface and admin console files.
To run ActiveMQ as a service, you need to create an ActiveMQ service unit file under the user called activemq, so start by creating the user using the useradd command as shown.
# useradd activemq
Next, set the correct permissions on the ActiveMQ installation directory and all of its contents belong to the newly created user and group. Besides, confirm that the new permissions are set as follows.
# chown -R activemq:activemq /opt/apache-activemq-5.16.4 # ls -l /opt/apache-activemq-5.16.4/Setting Permissions on ActiveMQ
Now create a service unit file for ActiveMQ called activemq.service
under /etc/systemd/system/ directory.
# vi /etc/systemd/system/activemq.service
Add the following configuration in the activemq.service
file.
[Unit] Description=Apache ActiveMQ Message Broker After=network-online.target [Service] Type=forking User=activemq Group=activemq WorkingDirectory=/opt/apache-activemq-5.16.4/bin ExecStart=/opt/apache-activemq-5.16.4/bin/activemq start ExecStop=/opt/apache-activemq-5.16.4/bin/activemq stop Restart=on-abort [Install] WantedBy=multi-user.target
Save the file and close it. Then reload the systemd manager configuration to read the newly created service, using the following command.
# systemctl daemon-reloadCreate ActiveMQ Service Unit File
Next, you can use the systemctl commands to start. enable and check the status of Apache ActiveMQ service as shown.
# systemctl start activemq.service # systemctl enable activemq.service # systemctl status activemq.serviceStart ActiveMQ Service
By default, the ActiveMQ daemon listens on port 61616 and you can confirm the port using the ss utility as follows.
# ss -ltpnCheck ActiveMQ Port
Before you can access the ActiveMQ web console, if you have the firewalld service running (which should be by default), you need to open port 8161 which the web console listens on in the firewall, using the firewall-cmd tool as shown.
# firewall-cmd --zone=public --permanent --add-port=8161/tcp # firewall-cmd --reloadTesting the ActiveMQ Installation
The ActiveMQ web console is used to manage and monitor ActiveMQ via a web browser. To access it open a web browser and point it to the following URL:
http://localhost:8161 OR http://SERVER_IP:8161
You will land on the following web interface.
ActiveMQ Web ConsoleTo start the actual administration of ActiveMQ, log into the admin web console by clicking on the 「Manager ActiveMQ broker」 link. Alternatively, the following URL will also take you directly to the admin web console login interface.
http://localhost:8161/admin OR http://SERVER_IP:8161/admin
Then use the default username admin and password admin to log in.
ActiveMQ Admin LoginThe following screenshot shows the web console dashboard, with various features to manage and monitor ActiveMQ.
ActiveMQ Admin Web Console SummaryIn this article, we have explained how to install the latest version of Apache ActiveMQ on CentOS 8 and RHEL 8 Linux distribution. If you want to know more information, especially about how to use Apache ActiveMQ, read the official ActiveMQ 5 documentation. Do not forget to send us your feedback via the comment form below.