Apache ActiveMQ is a modern, open source messaging platform. For years now, the community has been working on the successor to the venerable ActiveMQ - now sometimes referred to as ActiveMQ classic.

The new project is named ActiveMQ Artemis, at least until the time that it will be re-branded as ActiveMQ 6.0. Apparently that will happen once ActiveMQ Artemis has all features of ActiveMQ, but since no one knows if and when this feature parity is achieved lets take a look at ActiveMQ Artemis - the future of the ActiveMQ project.

ActiveMQ Artemis

The newer ActiveMQ Artemis is in fact the current releases from the ActiveMQ project - the classic ActiveMQ only receives security and bug fix updates but no new features. As such ActiveMQ Artemis has a number of features, that are unavailable to classic ActiveMQ and are unlikely to ever be implemented there:

  • JMS 2.0 support
  • A modern administrative web console - many more features exposed

Also ActiveMQ Artemis should be much more efficient than classic.

Prerequisites

At the time of writing this tutorial Apache ActiveMQ Artemis 2.15.0 is the latest release, and the following text assumes this version. It may or may not work with other releases - tread carefully and use common sense if you are using another release.

This tutorial will be using Linux - but the procedure would be very similar on Windows, with the usual differences in shell, services etc.

Just as ActiveMQ classic, Artemis is implemented in Java and as such it requires a JRE or JDK to run. I am on Fedora Linux and have stock OpenJDK installed. For Windows users, i can recommend AdoptOpenJDK. Artemis requires JDK 7 or later.

Download

Apache ActiveMQ Artemis can be downloaded at http://activemq.apache.org/components/artemis/download/

Here is a direct link for the tar.gz of version 2.15.0.

Unpack the tar.gz file

tar xf apache-artemis-2.15.0.tar.gz

That should give you a directory named apache-artemis-2.15.0.

Create a broker

ActiveMQ Artemis cannot run directly from the unpacked directory. Instead one has to create a dedicated broker. The purpose of this extra step is to make it easier to upgrade as the broker implementation is separated from the data and configuration.

A small broker can be created using the following command

./apache-artemis-2.15.0/bin/artemis create mybroker

which would create a broker called mybroker in the directory mybroker. The artemis command will ask questions for the mandatory arguments, if they are not given explicitly.

The following is what this would look like.

$ ./apache-artemis-2.15.0/bin/artemis create mybroker
Creating ActiveMQ Artemis instance at: /home/foo/mybroker

--user: is a mandatory property!
Please provide the default username:
admin

--password: is mandatory with this configuration:
Please provide the default password:


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

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

You can now start the broker by executing:

   "/home/foo/mybroker/bin/artemis" run

Or you can run the broker in the background using:

   "/home/foo/mybroker/bin/artemis-service" start

As you can see, an admin user and password was setup and anonymous access was disallowed.

Starting up

Once the broker has been created it can be started

./mybroker/bin/artemis run

The following would be output:

$ ./mybroker/bin/artemis run
     _        _               _
    / \  ____| |_  ___ __  __(_) _____
   / _ \|  _ \ __|/ _ \  \/  | |/  __/
  / ___ \ | \/ |_/  __/ |\/| | |\___ \
 /_/   \_\|   \__\____|_|  |_|_|/___ /
 Apache ActiveMQ Artemis 2.15.0


2020-10-05 10:41:23,736 INFO  [org.apache.activemq.artemis.integration.bootstrap] AMQ101000: Starting ActiveMQ Artemis Server
2020-10-05 10:41:23,825 INFO  [org.apache.activemq.artemis.core.server] AMQ221000: live Message Broker is starting with configuration Broker Configuration (clustered=false,journalDirectory=data/journal,bindingsDirectory=data/bindings,largeMessagesDirectory=data/large-messages,pagingDirectory=data/paging)
2020-10-05 10:41:23,867 INFO  [org.apache.activemq.artemis.core.server] AMQ221012: Using AIO Journal
2020-10-05 10:41:23,939 INFO  [org.apache.activemq.artemis.core.server] AMQ221057: Global Max Size is being adjusted to 1/2 of the JVM max size (-Xmx). being defined as 1,073,741,824
2020-10-05 10:41:23,977 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-server]. Adding protocol support for: CORE
2020-10-05 10:41:23,978 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-amqp-protocol]. Adding protocol support for: AMQP
2020-10-05 10:41:23,979 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-hornetq-protocol]. Adding protocol support for: HORNETQ
2020-10-05 10:41:23,979 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-mqtt-protocol]. Adding protocol support for: MQTT
2020-10-05 10:41:23,980 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-openwire-protocol]. Adding protocol support for: OPENWIRE
2020-10-05 10:41:23,980 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-stomp-protocol]. Adding protocol support for: STOMP
2020-10-05 10:41:24,086 INFO  [org.apache.activemq.artemis.core.server] AMQ221034: Waiting indefinitely to obtain live lock
2020-10-05 10:41:24,087 INFO  [org.apache.activemq.artemis.core.server] AMQ221035: Live Server Obtained live lock
2020-10-05 10:41:24,444 INFO  [org.apache.activemq.artemis.core.server] AMQ221080: Deploying address DLQ supporting [ANYCAST]
2020-10-05 10:41:24,446 INFO  [org.apache.activemq.artemis.core.server] AMQ221003: Deploying ANYCAST queue DLQ on address DLQ
2020-10-05 10:41:24,462 INFO  [org.apache.activemq.artemis.core.server] AMQ221080: Deploying address ExpiryQueue supporting [ANYCAST]
2020-10-05 10:41:24,463 INFO  [org.apache.activemq.artemis.core.server] AMQ221003: Deploying ANYCAST queue ExpiryQueue on address ExpiryQueue
2020-10-05 10:41:24,902 INFO  [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:61616 for protocols [CORE,MQTT,AMQP,STOMP,HORNETQ,OPENWIRE]
2020-10-05 10:41:24,906 INFO  [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:5445 for protocols [HORNETQ,STOMP]
2020-10-05 10:41:24,913 INFO  [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:5672 for protocols [AMQP]
2020-10-05 10:41:24,928 INFO  [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:1883 for protocols [MQTT]
2020-10-05 10:41:24,935 INFO  [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:61613 for protocols [STOMP]
2020-10-05 10:41:24,940 INFO  [org.apache.activemq.artemis.core.server] AMQ221007: Server is now live
2020-10-05 10:41:24,940 INFO  [org.apache.activemq.artemis.core.server] AMQ221001: Apache ActiveMQ Artemis Message Broker version 2.15.0 [0.0.0.0, nodeID=7aac120f-06e0-11eb-bf7d-28cfe9104e55]
2020-10-05 10:41:25,355 INFO  [org.apache.activemq.hawtio.branding.PluginContextListener] Initialized activemq-branding plugin
2020-10-05 10:41:25,442 INFO  [org.apache.activemq.hawtio.plugin.PluginContextListener] Initialized artemis-plugin plugin
2020-10-05 10:41:25,929 INFO  [io.hawt.HawtioContextListener] Initialising hawtio services
2020-10-05 10:41:25,959 INFO  [io.hawt.system.ConfigManager] Configuration will be discovered via system properties
2020-10-05 10:41:25,963 INFO  [io.hawt.jmx.JmxTreeWatcher] Welcome to hawtio 1.5.12 : http://hawt.io/ : Don't cha wish your console was hawt like me? ;-)
2020-10-05 10:41:25,967 INFO  [io.hawt.jmx.UploadManager] Using file upload directory: /home/foo/mybroker/tmp/uploads
2020-10-05 10:41:25,991 INFO  [io.hawt.web.AuthenticationFilter] Starting hawtio authentication filter, JAAS realm: "activemq" authorized role(s): "amq" role principal classes: "org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal"
2020-10-05 10:41:26,027 INFO  [io.hawt.web.JolokiaConfiguredAgentServlet] Jolokia overridden property: [key=policyLocation, value=file:/home/foo/mybroker/etc/jolokia-access.xml]
2020-10-05 10:41:26,066 INFO  [io.hawt.web.RBACMBeanInvoker] Using MBean [hawtio:type=security,area=jmx,rank=0,name=HawtioDummyJMXSecurity] for role based access control
2020-10-05 10:41:26,252 INFO  [io.hawt.system.ProxyWhitelist] Initial proxy whitelist: [localhost, 127.0.0.1, 192.168.10.167, marshmellow.lan]
2020-10-05 10:41:26,610 INFO  [org.apache.activemq.artemis] AMQ241001: HTTP Server started at http://localhost:8161
2020-10-05 10:41:26,610 INFO  [org.apache.activemq.artemis] AMQ241002: Artemis Jolokia REST API available at http://localhost:8161/console/jolokia
2020-10-05 10:41:26,611 INFO  [org.apache.activemq.artemis] AMQ241004: Artemis Console available at http://localhost:8161/console

This output is what one would expect a Java project startup to look like. Lets highlight some interesting points:

AMQ221020: Started EPOLL Acceptor at 0.0.0.0:61616 for protocols [CORE,MQTT,AMQP,STOMP,HORNETQ,OPENWIRE]
AMQ221020: Started EPOLL Acceptor at 0.0.0.0:5445 for protocols [HORNETQ,STOMP]
AMQ221020: Started EPOLL Acceptor at 0.0.0.0:5672 for protocols [AMQP]
AMQ221020: Started EPOLL Acceptor at 0.0.0.0:1883 for protocols [MQTT]
AMQ221020: Started EPOLL Acceptor at 0.0.0.0:61613 for protocols [STOMP]

We can see, the different transport protocols that have been started by default. In order to accept connections on these ports, we may need to open some firewall ports!

AMQ241004: Artemis Console available at http://localhost:8161/console

Also the console is available at http://localhost:8161/console. Lets try that and login using the admin account we created during broker creation.

ActiveMq Artemis Web Console
ActiveMq Artemis Web Console

A note regarding production quality

Many people seem to be under the impression that ActiveMQ Artemis is the development branch of ActiveMQ. Nothing could be further from the truth - the only reason ActiveMQ Artemis has not replaced the classic ActiveMQ is because Artemis does not have all features of classic.

In fact the open source ActiveMQ Artemis is used as part of the Red Hat AMQ 7 enterprise offering. So even an upgrade to commercial supported version may be possible if that is (or becomes) a requirement.

Conclusion

And that’s it for now. Future installments will go into further details on how to setup ActiveMQ Artemis for a fail-over / high-availability setup and how to upgrade ActiveMQ Artemis. Stay tuned.

Thilo Bangert

Senior Systems Consultant at Redpill Linpro

Thilo is a systems engineer working with integration and helping customers apply DevOps methodologies. He is hailing from the Copenhagen office and can be contacted by mail using thilo at redpill-linpro dot com.

Containerized Development Environment

Do you spend days or weeks setting up your development environment just the way you like it when you get a new computer? Is your home directory a mess of dotfiles and metadata that you’re reluctant to clean up just in case they do something useful? Do you avoid trying new versions of software because of the effort to roll back software and settings if the new version doesn’t work?

Take control over your local development environment with containerization and Dev-Env-as-Code!

... [continue reading]

Ansible-runner

Published on February 27, 2024

Portable Java shell scripts with Java 21

Published on February 21, 2024