Apache ActiveMQ is a widely used messaging server written in Java. As messaging services commonly do, it creates a bridge between heterogeneous systems for reliable data exchange in the form of messages pushed into queues by producer clients, where they wait to be “read”, or consumed by consumer clients.
Naturally a system that is client to ActiveMQ can be both producer and consumer, and more than one systems can subscribe to a queue or topic, thus enabling flexible communication between these client systems. Many different platforms and protocols can be used to connect to ActiveMQ, increasing it’s usefulness even more.
In this tutorial we will install Apache ActiveMQ on Red Hat Enterprise Linux 8 from tarball, add the systemd
unit files for ease of use, and access the admin page of our new service to create a queue.
In this tutorial you will learn:
- How to install ActiveMQ from tarball
- How to set up environment from the command line
- How to add systemd unit files for ActiveMQ
- How to access the admin page
Software Requirements and Conventions Used
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Red Hat Enterprise Linux 8 |
Software | Apache ActiveMQ 5.15.8 |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
How to install activemq on Redhat 8 step by step instructions
Apache ActiveMQ requires a working Java 8 installation, and nothing more. We should keep in mind that messages will be held on disk, so appropriate space needed. In this tutorial we will not give real load to the server, the queue we create will not consume space, as it will be empty.
- To find the package we need, we can check out the home page of the release. We can find the URL there, which can be given to
wget
. We’ll install the application under the/opt
directory, so we enter it:# cd /opt
And download the package using the URL we aquired from the website:
# 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
The site is clever enough to redirect us to the package on the closest mirror, but
wget
needs double quotes to handle the URL, and we can specify the name of the output file with-O
, avoiding an URL as filename. - We’ll extract the archive inplace:
# tar -xvf apache-activemq-5.15.8-bin.tar.gz
- We add a symlink pointing to it that has a more user-friendly name:
# ln -s /opt/apache-activemq-5.15.8 /opt/activemq
- For security’s sake, we do not run the service as
root
(nothing should run as root if does not need to). We create a useractivemq
, and the service will run in it’s name:# useradd activemq
- We set this new user as the owner of the contents of the extracted package, recursively:
# chown -R activemq:activemq apache-activemq-5.15.8*
- We create a unit file,
/etc/systemd/system/activemq.service
, that will hold the definition of the service:[Unit] Description=Apache ActiveMQ After=network.target [Service] Type=forking User=activemq Group=activemq ExecStart=/opt/activemq/bin/activemq start ExecStop=/opt/activemq/bin/activemq stop [Install] WantedBy=multi-user.target
- We need to reload
systemd
in order to notice the new service:# systemctl daemon-reload
- And from now on, we can manage: start, stop, and get it’s status:
# systemctl start|stop|status activemq
- If we plan to use this service on a regular basis, we can order
systemd
to start the service on every boot:# systemctl enable activemq
- To ensure all is working fine, after starting the service, we can check it’s logfile, which is
/opt/activemq/data/activemq.log
in our case. In this file, we can find an entry indicating that it is reachable with a browser:2019-01-15 15:59:14,359 | INFO | ActiveMQ WebConsole available at http://0.0.0.0:8161/ | org.apache.activemq.web.WebConsoleStarter | main
- Port
8161
is the default port for ActiveMQ. If our machine is running a firewall, we need to open this port to access the WebConsole:# firewall-cmd --zone=public --add-port=8161/tcp --permanent success # firewall-cmd --reload success
- Now we can access our ActiveMQ WebConsole by pointing a browser to the machine’s hostname or IP address, port 8161, appending the URL with
/admin
, to see more than a welcome page and some links.This page will require authentication. As we did not change the default configuration, we can guess what the default username and password could be. Hint: let’s try admin/admin.
- Our ActiveMQ server is up and running, and we can manage it from the WebConsole. For example by clicking the “Queues” link, we can create a queue (empty on the below picture):
We can start attaching clients to our ActiveMQ server, and provide it with messages to queue and forward to consumers when needed.