How to Install Apache ActiveMQ on CentOS/RHEL 8

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 8

To 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 -l 
ActiveMQ Files
ActiveMQ 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.

Running ActiveMQ as a Service Under Systemd

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
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-reload
Create ActiveMQ Service Unit File
Create 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.service
Start ActiveMQ Service
Start ActiveMQ Service

By default, the ActiveMQ daemon listens on port 61616 and you can confirm the port using the ss utility as follows.

# ss -ltpn 
Check ActiveMQ Port
Check 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 --reload

Testing 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 Console
ActiveMQ Web Console

To 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 Login
ActiveMQ Admin Login

The following screenshot shows the web console dashboard, with various features to manage and monitor ActiveMQ.

ActiveMQ Admin Web Console
ActiveMQ Admin Web Console
Summary

In 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.

Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

4 thoughts on “How to Install Apache ActiveMQ on CentOS/RHEL 8”

  1. The wget command to install ActiveMQ didn’t work for me, I used the following instead:

    # wget "http://www.apache.org/dyn/closer.cgi&filename=/activemq/5.15.8/apache-activemq-5.15.8-bin.tar.gz&action=download" -O apache-activemq-5.15.8-bin.tar.gz

    Reply
    • @Chitusha

      The primary function of a Message Broker is processing messages. If you are building an enterprise with microservices (architecture), then you need a message broker to create a centralized store/processor for these messages, so that other applications or users can work with these messages. The ApacheMQ documentation has so many use cases and examples of applications using AMQ: https://activemq.apache.org/projects-using-activemq.html.

      Reply

Leave a Reply to Jada Cancel reply

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.