21 C
Texas
angeloma
Senior Writer and partner

Install Apache ActiveMQ on Ubuntu 20.04 / 18.04

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 20.04 / 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.

Besides being able to be used in Java, ActiveMQ can also be used in .NET, C/C++ or Delphi or from script languages such as Perl, Python, PHP, and Ruby through various “cross-language clients”.

So, let us start.

1. Install Java

- Advertisement -

If you use Ubuntu 20.04 / 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
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  at-spi2-core ca-certificates-java fontconfig-config fonts-dejavu-core fonts-dejavu-extra java-common libatk-bridge2.0-0 libatk-wrapper-java libatk-wrapper-java-jni
  libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1
  libfontconfig1 libfontenc1 libgif7 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libice6 libjpeg-turbo8 libjpeg8 liblcms2-2 libllvm10 libnspr4
  libnss3 libpciaccess0 libpcsclite1 libsensors-config libsensors5 libsm6 libvulkan1 libwayland-client0 libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0
  libxcb-present0 libxcb-randr0 libxcb-shape0 libxcb-sync1 libxcomposite1 libxdamage1 libxfixes3 libxft2 libxi6 libxinerama1 libxkbfile1 libxmu6 libxpm4 libxrandr2
  libxrender1 libxshmfence1 libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 mesa-vulkan-drivers openjdk-11-jre-headless x11-common x11-utils
Suggested packages:
  default-jre cups-common liblcms2-utils pcscd lm-sensors libnss-mdns fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei fonts-indic
  mesa-utils
The following NEW packages will be installed:
  at-spi2-core ca-certificates-java fontconfig-config fonts-dejavu-core fonts-dejavu-extra java-common libatk-bridge2.0-0 libatk-wrapper-java libatk-wrapper-java-jni
  libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1
  libfontconfig1 libfontenc1 libgif7 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libice6 libjpeg-turbo8 libjpeg8 liblcms2-2 libllvm10 libnspr4
  libnss3 libpciaccess0 libpcsclite1 libsensors-config libsensors5 libsm6 libvulkan1 libwayland-client0 libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0
  libxcb-present0 libxcb-randr0 libxcb-shape0 libxcb-sync1 libxcomposite1 libxdamage1 libxfixes3 libxft2 libxi6 libxinerama1 libxkbfile1 libxmu6 libxpm4 libxrandr2
  libxrender1 libxshmfence1 libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 mesa-vulkan-drivers openjdk-11-jre openjdk-11-jre-headless x11-common x11-utils
0 upgraded, 74 newly installed, 0 to remove and 83 not upgraded.
Need to get 72.6 MB of archives.

1.- Installing Java on Ubuntu 20.04
1.- Installing Java on Ubuntu 20.04 / 18.04

Next, check the java version to ensure that everything is Ok.

:~$ java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)

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 -c http://mirrors.advancedhosters.com/apache/activemq/5.16.0/apache-activemq-5.16.0-bin.tar.gz

2.- Download Apache ActiveMQ
2.- Download Apache ActiveMQ

Decompress it.

:~$ sudo tar xzvf apache-activemq-5.16.0-bin.tar.gz

Then, create a symbolic link to make easier the access.

:~$ sudo ln -s apache-activemq-5.16.0 activemq

Then, create a new user for ActiveMQ. Assign permissions to the folder and then log in as that new user.

$ sudo useradd activemq
$ sudo chown -RH activemq: /opt/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

3.- Creating a systemd service
3.- Creating a systemd service

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

Also, you can use the newly created service:

:~$ sudo systemctl start activemq

Or stop it with this command:

:~$ /opt/activemq/bin/activemq stop

6.- Start and stop the ActiveMQ program
4.- Start and stop the ActiveMQ program

Next, let us configure it.

Open the activem.xml file. This file contains all ActiveMQ settings.

:~$ sudo nano /opt/activemq/conf/activemq.xml

7.- The config file
5.- The config file

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

8.-Config file
6.-Config file

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.

9.- Creating a transport connector
7.- Creating a transport connector

System usage

It is also possible to limit the use of system resources. In the same file in the system usage section, you can configure it.

10.- System usage
8.- System usage

There you can limit, for example, the use of the hard disk and the RAM memory.

Finals settings

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.

11.- Limit the messages
9.- Limit the messages

Another 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

12.- ActiveMQ web interface
10.- ActiveMQ web interface

Conclusion

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. Join our Telegram Channel.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article