On an enterprise server, many important applications are likely to cohabit. The need for a broker makes more sense if these applications are constantly transferring information. In addition, an organization’s scalable infrastructure depends on the quality of the applications. Therefore, in this post, I will show you how to install Apache ActiveMQ on Ubuntu 18.04.
In computing, the term broker defines an intermediary between two or more applications that need resources and information between them. So, Apache ActiveMQ is the most popular and powerful open source messaging and Integration Patterns server. It is open source licensed under the Apache 2.0 License.
So, let us start.
1. Install Java
If you use Ubuntu 18.04 it is unlikely that you do not have Java installed, however, you can do it in an easy way with the following command:
:~$ sudo apt install openjdk-11-jre
Next, check the java version to ensure that everything is Ok.
:~$ java -version
This first step is vital because Apache ActiveMQ requires Java to work. That’s why we had to install it.
2. Install Apache ActiveMQ
Now we can continue with the installation. The best way to install Apache ActiveMQ is through your binaries that we can get from your website. With this, you guarantee that you will have the latest stable version available.
First, download the file.
:~$ cd /opt/ :~$ sudo wget http://archive.apache.org/dist/activemq/5.15.8/apache-activemq-5.15.8-bin.tar.gz
:~$ sudo tar xzvf apache-activemq-5.15.8-bin.tar.gz
Then, create a symbolic link to make easier the access.
:~$ sudo ln -s apache-activemq-5.15.8 activemq
3. Configure Apache ActiveMQ
First of all, it is necessary to create a systemd service in order to access the program even more easily. To do this, run:
:~$ sudo nano /etc/systemd/system/activemq.service
And add the following:
[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
Now, reload the systemd cache.
:~$ sudo systemctl daemon-reload
NOTE: It is not mandatory to create the file to transform ActiveMQ into a systemd service and in some cases, it can cause problems.
You can also start ActiveMQ with this command:
:~$ /opt/activemq/bin/activemq start
Or stop it with this command:
:~$ /opt/activemq/bin/activemq stop
Next, let us configure it.
Open the activem.xml file. This file contains all ActiveMQ settings.
:~$ sudo nano /opt/activemq/conf/activemq.xml
Creating a transport connector
The first step is to configure the transport connector. Edit the file in question and place it in the transport connector section.
It’s a pretty large file, but with the help of nano, we can quickly find the sections. Press CTRL + W and type “transport”.
The syntax is very simple:
- broker_name: is the brokerName attribute of the tag broker of activemq.xml
- transportOptions: different communication options.
Now, the parameters URI is the in the connection type function. For example, you can specify a broker using TCP or VM.
Let us see an example:
<transportConnection name="openwire" uri="tcp://192.168.3.4:8765?trace=false&soTimeout=60000">
On the URI option, you have to add the protocol, the port, and the options.
It is also possible to limit the use of system resources. In the same file in the system usage section, you can configure it.
There you can limit, for example, the use of the hard disk and the RAM memory.
These are basic ActiveMQ configurations. One thing you can do is prevent the storage buffer from ending up with all the RAM. For that, in the same configuration file go to the policy entry section.
You can limit all the messages to a specific size.
Other thing ActiveMQ has a built-in database manager called KahaDB that is mainly in charge of storing messages. You can replace it with MySQL or MariaDB but KahaDB is very superior in performance, so it is not recommended to do this.
Finally, start ActiveMQ. Then, open your web browser and go to http://SERVER_IP:8161.
:~$ /opt/activemq/bin/activemq start
It is clear that ActiveMQ is an enterprise infrastructure software. Known and very popular for being efficient and a benchmark in its area.
Please share this post with your friends.