Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / Apache

Install & Configure ActiveMQ - Artemis on Linux Ubuntu 18.04.x

0.00/5 (No votes)
8 May 2020CPOL5 min read 19.3K  
How to install/configure the Artemis on the Linux Ubuntu 18.04.x OS
This article is part of the research for “Enterprise Data Bus System”. This particular research elects the ActiveMQ - Artemis (Artemis from here on) as the centralized message hub for all processes in the system to communicate with one another using one of the supported protocols by the Artemis. In this article, I will be discussing the procedure to install/configure the Artemis on the Linux Ubuntu 18.04.x OS that is running on an ARM64 machine.

Assumption/Expectation

The Linux Commands and Vim

I am assuming the readers of this article have some knowledge about the Linux shell and commands, and an explanation of the Linux commands that were used is beyond the scope of this article. The Linux commands are to be run in a terminal unless otherwise specified.

I’m using the vim editor for text editing, but readers can use any other text editor they desire.

'root' User

All commands in this article are issued by the root user.

Background

Message-oriented Middleware (MoM)

Message-oriented middleware (MoM) is software or hardware infrastructure supporting, sending, and receiving messages between distributed systems.

Why Use MoM?

MoM allows application modules to be distributed over heterogeneous platforms and reduces the complexity of developing applications that span multiple operating systems, network protocols, and programming languages. MoM enable processes in the system to communicate through one of the well-defined protocols by providing reliability, transactions and many other features.

Apache ActiveMQ Artemis

Apache ActiveMQ Artemis (Artemis) is an asynchronous messaging system, and is a software implementation of the MoM system. The Artemis is capable of coordinating the messaging traffic between processes in the distributed systems through an instance of a running broker.

Message Protocols Supported by Artemis

The Artemis supports the following protocols:

  • MPQOpenWire
  • MQTT
  • STOMP
  • HornetQ (for use with HornetQ clients)
  • Core (Artemis CORE protocol)

For example, in a three-tier system, there may be some processes written in Java, C/C++, Python. GoLang, nodejs, etc. running distributively at front-end, middle-tier, and back-end. These processes can communicate to one another (e.g., using the STOMP protocol) by registering themselves to a named-queue or a topic to send/receive messages.

System Information

  • Hardware: Odroid N2 (ARM 64)
  • OS: Ubuntu 18.04.4 LTS (Bionic Beaver)

JAVA (openjdk-11) Installation

The Artemis needs JRE (with at least version 8) to run. The following is the procedure for openjdk-11 installation/configuration.

Installation:

sudo apt install openjdk-11-jdk 

Verify:

which java

/usr/bin/java

java --version

openjdk 11.0.7 2020-04-14

OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-2ubuntu218.04)

OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-2ubuntu218.04, mixed mode)

Post-install Configuration: Set JAVA_HOME Environment Variable

The Artemis requires that the JAVA_HOME environment to be set. The following are the steps to set it in /etc/bash.bashrc and activate it.

Determine the Absolute Path of the JDK Installed Directory

In Ubuntu, the jdks are installed under /usr/lib/jvm. The binaries in jdk builds are platform-specific; therefore, the JAVA_HOME variable must point to a platform specific installed JDK (in this case, the platform is ARM64).

This is what it looks like under /usr/lib/jvm:

pwd
/usr/lib/jvm

ls
java-1.11.0-openjdk-arm64 java-11-openjdk-arm64  openjdk-11

So the JAVA_HOME enivironment variable should be set to “/usr/lib/jvm”.

Setting JAVA_HOME in /etc/bash.bashrc

Edit the file /etc/bash.bashrc:

vim /etc/bash.bashrc

Add the following lines (at the bottom of this file):

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64

Sourcing the script:

source /etc/bash.bashrc

Verify the variable’s value:

echo $JAVA_HOME

/usr/lib/jvm/java-11-openjdk-arm64

2. ActiveMQ-Artemis Installation/Configuration

Download the Artemis from Apache.org

Open the web browser and point to the following URL:

http://activemq.apache.org/components/artemis/download/

The URL for source and binary bundles:

http://activemq.apache.org/components/artemis/download/

Image 1

Figure 1: ActiveMQ Artemis download page

Note:

  • I used the tar ball for this tutorial (the file in this example is resided in /media/SDA1).
  • The ActiveMQ server and its brokers will be installed in “/opt” directory.
  • The broker name I’ll be using is `ActiveMQ-Odroid-110`.

Extract the Downloaded Bundle

pwd
/opt

tar -xzf /media/SDA1/apache-artemis-2.12.0-bin.tar.gz

Verify:

ls

(among other things…) apache-artemis-2.12.0

Create a New Linux User Group `activemq`

addgroup --quiet --system activemq

Create a New Linux User `activemq`

adduser --quiet --system --ingroup activemq \
--no-create-home --disabled-password activemq

Change the Ownership of `/opt/apache-artemis-2.12.0` Directory

chown -R activemq:activemq /opt/activemq

Navigate to the `bin` Directory

cd apache-artemis-2.12.0/bin

Verify:

./artemis

If you see the following output, then you’re ready for the broker installation:

usage: artemis <command> [<args>]

The most commonly used artemis commands are:

    address     Address tools group (create|delete|update|show) 
                (example ./artemis address create)
    browser     It will browse messages on an instance
    consumer    It will consume messages from an instance
    create      creates a new broker instance
    data        data tools group (print) (example ./artemis data print)
    help        Display help information
    mask        mask a password and print it out
    migrate1x   Migrates the configuration of a 1.x Artemis Broker
    producer    It will send messages to an instance
    queue       Queue tools group (create|delete|update|stat|purge) 
                (example ./artemis queue create)

See 'artemis help <command>' for more information on a specific command.

Create the Broker

In this example, the broker will have the following properties:

  • Name: ActiveMQ-Odroid-110
  • Administrator UID: admin
  • Administrator PW: admin
./artemis create ActiveMQ-Odroid-110 --user=admin --password=admin \
--http-host 0.0.0.0 --relax-jolokia

... the installation will have an additional prompt (just type "Y" and press Enter):

--allow-anonymous | --require-login: is a mandatory property!
Allow anonymous access?, valid values are Y,N,True,False

Y      <--- Enter

The rest of the output:

Auto tuning journal ...
done! Your system can make 1.61 writes per millisecond, 
your journal-buffer-timeout will be 620000

You can now start the broker by executing:
   "/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis" run
Or you can run the broker in the background using:
   "/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service" start
   
   "/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service"
Usage: ./artemis-service {start|stop|restart|force-stop|status}

Start the Broker Instance

Now, we’re ready to run the broker:

Test Run #1: Manually Start the Broker for Test Run

"/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis" run

Now, open the web browser and point it to the website at:

http://<IP of the broker>:8161

If you see the following webpage, the broker instance is up and running successfully:

Image 2

Figure 2: ActiveMQ initial webpage

Click on `Management Console` link to open the login page (Note: Username=admin, Password=admin as specified during broker’s creation previously).

Image 3

Figure 3: ActiveMQ login page

ActiveMQ Management Console initial page:

Image 4

Figure 4: ActiveMQ Management Console initial page

Congratulations, you have successfully installed the first ActiveMQ broker!

Test Run #2: Start the Broker as Daemon Process

To run the broker as a background service, first kill the current instance of the broker (i.e., Ctrl+C at the console where the broker is running), then run this command:

"/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service" start

Output:

Starting artemis-service
artemis-service is now running (14289)

Verify:

ps -ef| grep 14289

Output:

root     14289     1 10 18:18 pts/0    00:00:23 /usr/lib/jvm/java-11-openjdk-arm64/bin/java
-XX:+PrintClassHistogram -XX:+UseG1GC -XX:+UseStringDeduplication -Xms512M -Xmx2G
-Dhawtio.realm=activemq -Dhawtio.offline=true -Dhawtio.role=amq
-Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal
-Djolokia.policyLocation=file:/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/etc/jolokia-
access.xml -Xbootclasspath/a:/opt/apache-artemis-2.12.0/lib/jboss-logmanager-2.1.10.Final.jar:
/opt/apache-artemis-2.12.0/lib/wildfly-common-1.5.2.Final.jar 
-Djava.security.auth.login.config=/opt
/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/etc/login.config 
-classpath /opt/apache-artemis-2.12.0
/lib/artemis-boot.jar -Dartemis.home=/opt/apache-artemis-2.12.0 -Dartemis.instance=/opt/apache-
artemis-2.12.0/bin/ActiveMQ-Odroid-110 
-Djava.library.path=/opt/apache-artemis-2.12.0/bin/lib/linux-
aarch64 -Djava.io.tmpdir=/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/tmp -Ddata.dir=/opt
/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/data -Dartemis.instance.etc=/opt/apache-artemis-
2.12.0/bin/ActiveMQ-Odroid-110/etc -Djava.util.logging.manager=org.jboss.logmanager.LogManager
-Dlogging.configuration=file:/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/etc
//logging.properties org.apache.activemq.artemis.boot.Artemis run

Logout/login to the web console again to make sure everything is still working.

Now, stop the daemon process:

"/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service" stop

At this point, we are ready to create a new systemd service for the broker instance.

Create System Service for the Broker

At this point, we have tested the broker in both forth-ground and daemon process modes. However in these modes, the process will not survive system reboot. To prevent from manually restarting the broker process every time the system reboots, we need to create a system-service and let the Linux Operating System handle all start/stop automatically.

Create system-service Script

touch /etc/systemd/system/activemq-artemis.service

chmod 644 /etc/systemd/system/activemq-artemis.service

vim /etc/systemd/system/activemq-artemis.service

Add the following lines to the file:

[Unit]

Description=Apache ActiveMQ Artemis
After=network.target

[Service]

Type=forking
User=activemq
Group=activemq

ExecStart=/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service start
ExecStop=/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service stop

[Install]
WantedBy=multi-user.target

Load/start the service:

systemctl daemon-reload

systemctl start activemq-artemis

Enable the service (so it can survive system reboot):

systemctl enable activemq-artemis

Output:

Created symlink /etc/systemd/system/multi-user.target.wants/ 
activemq-artemis.service → /etc/systemd
/system/activemq-artemis.

Verify with system-service:

systemctl status activemq-artemis

Output should be similar to the following:

Loaded: loaded (/etc/systemd/system/activemq-artemis.service; enabled; vendor preset: enabled)

   Active: active (running) since Sat 2020-05-02 16:17:52 UTC; 34s ago

  Process: 2894 
  ExecStart=/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service start 
  (code=exited, sta

 Main PID: 2919 (java)

    Tasks: 50 (limit: 3838)

   CGroup: /system.slice/activemq-odroid-110.service

           └─2919 java -XX:+PrintClassHistogram -XX:+UseG1GC 
             -XX:+UseStringDeduplication -Xms512M -Xmx2G -Dhawtio.realm=


May 02 16:17:30 odroid systemd[1]: Starting Apache ActiveMQ Artemis...

May 02 16:17:30 odroid artemis-service[2894]: Starting artemis-service

May 02 16:17:52 odroid artemis-service[2894]: artemis-service is now running (2919)

May 02 16:17:52 odroid systemd[1]: Started Apache ActiveMQ Artemis.

Optionally, verify with the broker’s status report:

/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service status

Output should be similar to the following:

artemis-service is running (16934)

Test system stop the service:

systemctl stop activemq-odroid-110

Verify with system-service:

systemctl status activemq-odroid-110

The last couple lines output should be similar to the following:

May 02 16:35:13 odroid artemis-service[4031]: Gracefully Stopping artemis-service

May 02 16:35:14 odroid systemd[1]: activemq-odroid-110.service: 
                Main process exited, code=exited, status=143/n/a

May 02 16:35:14 odroid systemd[1]: activemq-odroid-110.service: 
                Failed with result 'exit-code'.

May 02 16:35:14 odroid systemd[1]: Stopped Apache ActiveMQ Artemis.

Verify with the broker’s status report:

/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service status

Output should be similar to the following:

artemis-service is stopped

Note on Create Additional Brokers

The Artemis supports multiple brokers running simultaneously on the same host, so one can follow the procedure in this tutorial to create additional brokers as needed.

This concludes the procedure for installing the Apache-Artemis on Linux Ubuntu/ARM64 system.

History

  • 8th May, 2020: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)