How to Install Apache ActiveMQ Classic on AlmaLinux 9 and Rocky Linux 9
Install the ActiveMQ Classic binary release on the RHEL 9 family, run it under systemd as its own user and lock down the web console.
Apache ActiveMQ Classic is a message broker that speaks JMS, AMQP, STOMP and MQTT. This guide installs the current ActiveMQ Classic 6 binary release on AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9, runs it as an unprivileged systemd service and secures the web console.
CentOS 7 reached end of life in June 2024, so new brokers belong on a RHEL 9 compatible release. The ActiveMQ project now ships two brokers: ActiveMQ Classic, the continuation of the 5.x broker covered here, and ActiveMQ Artemis, a separate broker with a different architecture and configuration. Classic is actively maintained; the project lists the 6.4.x, 6.3.x and 5.19.x series as active.
Requirements
- AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9 with a
sudouser. - Java 17 or newer for ActiveMQ Classic 6.x. The 5.19.x series, which still uses the older
javax.jmsAPI, runs on Java 11, 17 or 21. - At least 1 GB of free memory for the broker's JVM.
Choose 6.x for new installations. Stay on 5.19.x only if your applications cannot move to the Jakarta Messaging (jakarta.jms) client libraries yet.
Step 1: Install OpenJDK
Update the system and install the headless OpenJDK 21 runtime, which is enough for a server:
sudo dnf update -y
sudo dnf install -y java-21-openjdk-headless tar wget
Check the version:
java -version
Step 2: Download and unpack ActiveMQ
Look up the latest release on the ActiveMQ Classic download page and put its number in a shell variable. The example uses 6.4.0; replace it with the version shown there.
AMQ_VERSION=6.4.0
cd /tmp
wget -O apache-activemq-${AMQ_VERSION}-bin.tar.gz "https://www.apache.org/dyn/closer.cgi?filename=/activemq/${AMQ_VERSION}/apache-activemq-${AMQ_VERSION}-bin.tar.gz&action=download"
Compare the file's checksum with the SHA-512 value linked next to the release on the download page:
sha512sum apache-activemq-${AMQ_VERSION}-bin.tar.gz
Unpack the archive into /opt and create a version-independent symbolic link, which makes later upgrades a matter of repointing the link:
sudo tar -xzf apache-activemq-${AMQ_VERSION}-bin.tar.gz -C /opt
sudo ln -sfn /opt/apache-activemq-${AMQ_VERSION} /opt/activemq
Step 3: Create a service user
A broker has no reason to run as root. Create a system account and hand it the installation directory:
sudo useradd --system --home-dir /opt/activemq --shell /sbin/nologin activemq
sudo chown -R activemq:activemq /opt/apache-activemq-${AMQ_VERSION}
Step 4: Create the systemd unit
The bin/activemq script has a console command that keeps the broker in the foreground, which is what systemd expects from a simple service. Create /etc/systemd/system/activemq.service:
sudo tee /etc/systemd/system/activemq.service > /dev/null <<'EOF'
[Unit]
Description=Apache ActiveMQ Classic message broker
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=activemq
Group=activemq
WorkingDirectory=/opt/activemq
ExecStart=/opt/activemq/bin/activemq console
SuccessExitStatus=143
Restart=on-failure
RestartSec=10
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOF
Load the unit and start the broker now and at every boot:
sudo systemctl daemon-reload
sudo systemctl enable --now activemq
Step 5: Verify that the broker is running
sudo systemctl status activemq
sudo ss -tlnp | grep -E '61616|8161'
Port 61616 is the OpenWire (JMS) listener and 8161 is the web console. The broker log is /opt/activemq/data/activemq.log; the same output is in the journal:
sudo journalctl -u activemq -n 50
Step 6: Change the default passwords
The web console accepts admin / admin until you change it. Console users live in /opt/activemq/conf/jetty-realm.properties. Edit the admin entry, keeping the format of the existing lines, and remove any other account you do not need:
sudo -u activemq vi /opt/activemq/conf/jetty-realm.properties
The file conf/credentials.properties holds the account that bundled components use to connect to the broker (system / manager by default). Change that password as well. Note that the default activemq.xml does not require client authentication on the broker ports at all; before exposing 61616 to other hosts, enable an authentication plugin as described in the ActiveMQ security documentation.
Restart to apply the changes:
sudo systemctl restart activemq
Step 7: Reach the web console
Current releases bind the web console to the loopback address. Check the setting:
grep -n -A4 'id="jettyPort"' /opt/activemq/conf/jetty.xml
With host set to 127.0.0.1, the safest way to use the console is an SSH tunnel from your workstation:
ssh -L 8161:127.0.0.1:8161 deploy@203.0.113.1
Then browse to http://127.0.0.1:8161/admin/ and log in. To test the broker, open Queues, create a queue and use Send To to post a message to it.
If the console must be reachable directly, change the host value in that bean to 0.0.0.0, restart ActiveMQ and allow only the addresses that need it. The same pattern opens the broker port to your application servers:
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="198.51.100.20" port port="61616" protocol="tcp" accept'
sudo firewall-cmd --reload
Upgrading
Download and unpack the new release next to the old one, copy your changed files from conf/ and the data/ directory across, fix ownership, repoint the /opt/activemq link and restart the service. Read the release notes first when you move between series, for example from 5.19 to 6.x.
Frequently asked questions
Should I install ActiveMQ Classic or Artemis?
Use Classic when you maintain applications written for ActiveMQ 5.x or need its configuration format and behaviour. Artemis is a different broker with its own storage engine, configuration and management console; it is a reasonable choice for new projects, but it is not a drop-in upgrade, so plan a migration rather than swapping binaries.
How do I change the broker's memory limits?
JVM options are set in /opt/activemq/bin/env. The start script reads the first of /etc/default/activemq, ~/.activemqrc and bin/env that exists, so copying bin/env to /etc/default/activemq keeps your heap settings outside the versioned directory and safe across upgrades.
Why can my old client not connect to ActiveMQ 6?
ActiveMQ Classic 6 moved from the javax.jms API to jakarta.jms. Applications built against the old client libraries need to be rebuilt with the Jakarta client, or you run the 5.19.x broker series until they are.
Which other ports does ActiveMQ open?
The default activemq.xml defines transport connectors for AMQP (5672), STOMP (61613), MQTT (1883) and WebSocket (61614) besides OpenWire on 61616. Remove the connectors you do not use from the transportConnectors section so they are not listening at all.