This chapter will familiarise you with how to use the Apache ActiveMQ Artemis server.

We’ll show where it is, how to start and stop it, and we’ll describe the directory layout and what all the files are and what they do.

This document will refer to the full path of the directory where the ActiveMQ distribution has been extracted to as ${ARTEMIS_HOME}.

1. Installation

You can get the latest release from the Download page.

The following highlights some important folders on the distribution:

  1. |___ bin
  2. |
  3. |___ lib
  4. |
  5. |___ schema
  6. |
  7. |___ web

bin

binaries and scripts needed to run ActiveMQ Artemis.

lib

jars and libraries needed to run ActiveMQ Artemis

schema

XML Schemas used to validate ActiveMQ Artemis configuration files

web

The folder where the web context is loaded when the broker runs.

2. Creating a Broker Instance

A broker instance is the directory containing all the configuration and runtime data, such as logs and message journal, associated with a broker process. It is recommended that you do not create the instance directory under ${ARTEMIS_HOME}. This separation is encouraged so that you can more easily upgrade when the next version of ActiveMQ Artemis is released.

On Unix systems, it is a common convention to store this kind of runtime data under the /var/lib directory. For example, to create an instance at /var/lib/mybroker, run the following commands in your command line shell:

Before the broker is used, a broker instance must be created. This process requires the use of the Command Line Interface which is better explained in its own chapter.

In the following example a broker instance named mybroker will be created:

  1. $ cd /var/lib
  2. $ ${ARTEMIS_HOME}/bin/artemis create mybroker

A broker instance directory will contain the following sub directories:

bin

holds execution scripts associated with this instance.

data

holds the data files used for storing persistent messages

etc

hold the instance configuration files

lib

holds any custom runtime Java dependencies like transformers, plugins, interceptors, etc.

log

holds rotating log files

tmp

holds temporary files that are safe to delete between broker runs

At this point you may want to adjust the default configuration located in the etc directory.

2.1. Options

There are several options you can use when creating an instance. For a full list of options use the help command:

  1. $ ./artemis help create
  2. Usage: artemis create [--aio] [--allow-anonymous] [--autocreate] [--autodelete]
  3. [--backup] [--blocking] [--clustered]
  4. [--disable-persistence] [--failover-on-shutdown]
  5. [--force] [--jdbc] [--linux] [--mapped] [--nio]
  6. [--no-amqp-acceptor] [--no-autocreate] [--no-autotune]
  7. [--no-fsync] [--no-hornetq-acceptor] [--no-mqtt-acceptor]
  8. [--no-stomp-acceptor] [--no-web] [--paging]
  9. [--relax-jolokia] [--replicated] [--require-login]
  10. [--shared-store] [--silent] [--slave]
  11. [--support-advisory]
  12. [--suppress-internal-management-objects]
  13. [--use-client-auth] [--verbose] [--windows]
  14. [--addresses=<addresses>]
  15. [--cluster-password=<clusterPassword>]
  16. [--cluster-user=<clusterUser>] [--data=<data>]
  17. [--default-port=<defaultPort>] [--encoding=<encoding>]
  18. [--etc=<etc>] [--global-max-messages=<globalMaxMessages>]
  19. [--global-max-size=<globalMaxSize>] [--home=<home>]
  20. [--host=<host>] [--http-host=<httpHost>]
  21. [--http-port=<httpPort>] [--java-memory=<javaMemory>]
  22. [--jdbc-bindings-table-name=<jdbcBindings>]
  23. [--jdbc-connection-url=<jdbcURL>]
  24. [--jdbc-driver-class-name=<jdbcClassName>]
  25. [--jdbc-large-message-table-name=<jdbcLargeMessages>]
  26. [--jdbc-lock-expiration=<jdbcLockExpiration>]
  27. [--jdbc-lock-renew-period=<jdbcLockRenewPeriod>]
  28. [--jdbc-message-table-name=<jdbcMessages>]
  29. [--jdbc-network-timeout=<jdbcNetworkTimeout>]
  30. [--jdbc-node-manager-table-name=<jdbcNodeManager>]
  31. [--jdbc-page-store-table-name=<jdbcPageStore>]
  32. [--journal-device-block-size=<journalDeviceBlockSize>]
  33. [--journal-retention=<retentionDays>]
  34. [--journal-retention-max-bytes=<retentionMaxBytes>]
  35. [--max-hops=<maxHops>]
  36. [--message-load-balancing=<messageLoadBalancing>]
  37. [--name=<name>] [--password=<password>] [--ping=<ping>]
  38. [--port-offset=<portOffset>] [--queues=<queues>]
  39. [--role=<role>] [--security-manager=<securityManager>]
  40. [--ssl-key=<sslKey>]
  41. [--ssl-key-password=<sslKeyPassword>]
  42. [--ssl-trust=<sslTrust>]
  43. [--ssl-trust-password=<sslTrustPassword>]
  44. [--staticCluster=<staticNode>] [--user=<user>]
  45. [--java-options=<javaOptions>]... <directory>
  46. Create a new broker instance.
  47. <directory> The instance directory to hold the broker's
  48. configuration and data. Path must be writable.
  49. --addresses=<addresses>
  50. A comma separated list of addresses with the
  51. option to specify a routing type, e.g.
  52. --addresses myAddress1,myAddress2:anycast.
  53. Routing-type default: multicast.
  54. --aio Set the journal as asyncio.
  55. --allow-anonymous Allow connections from users with no security
  56. credentials. Opposite of --require-login.
  57. Default: input.
  58. --autocreate Allow automatic creation of addresses & queues.
  59. Default: true.
  60. --autodelete Allow automatic deletion of addresses & queues.
  61. Default: false.
  62. --backup Be a backup broker. Valid for shared store or
  63. replication.
  64. --blocking Block producers when address becomes full.
  65. Opposite of --paging. Default: false.
  66. --cluster-password=<clusterPassword>
  67. The password to use for clustering. Default: input.
  68. --cluster-user=<clusterUser>
  69. The user to use for clustering. Default: input.
  70. --clustered Enable clustering.
  71. --data=<data> Directory where ActiveMQ data are stored. Paths
  72. can be absolute or relative to artemis.instance
  73. directory. Default: data.
  74. --default-port=<defaultPort>
  75. The port number to use for the main 'artemis'
  76. acceptor. Default: 61616.
  77. --disable-persistence Disable message persistence to the journal
  78. --encoding=<encoding> The encoding that text files should use. Default:
  79. UTF-8.
  80. --etc=<etc> Directory where ActiveMQ configuration is located.
  81. Paths can be absolute or relative to artemis.
  82. instance directory. Default: etc.
  83. --failover-on-shutdown Whether broker shutdown will trigger failover for
  84. clients using the core protocol. Valid only for
  85. shared store. Default: false.
  86. --force Overwrite configuration at destination directory.
  87. --global-max-messages=<globalMaxMessages>
  88. Maximum number of messages that will be accepted
  89. in memory before using address full policy mode.
  90. Default: undefined.
  91. --global-max-size=<globalMaxSize>
  92. Maximum amount of memory which message data may
  93. consume. Default: half of the JVM's max memory.
  94. --home=<home> Directory where ActiveMQ Artemis is installed.
  95. --host=<host> Broker's host name. Default: 0.0.0.0 or input if
  96. clustered).
  97. --http-host=<httpHost> Embedded web server's host name. Default:
  98. localhost.
  99. --http-port=<httpPort> Embedded web server's port. Default: 8161.
  100. --java-memory=<javaMemory>
  101. Define the -Xmx memory parameter for the broker.
  102. Default: 2G.
  103. --java-options=<javaOptions>
  104. Extra Java options to be passed to the profile.
  105. --jdbc Store message data in JDBC instead of local files.
  106. --jdbc-bindings-table-name=<jdbcBindings>
  107. Name of the jdbc bindings table.
  108. --jdbc-connection-url=<jdbcURL>
  109. The URL used for the database connection.
  110. --jdbc-driver-class-name=<jdbcClassName>
  111. JDBC driver classname.
  112. --jdbc-large-message-table-name=<jdbcLargeMessages>
  113. Name of the large messages table.
  114. --jdbc-lock-expiration=<jdbcLockExpiration>
  115. Lock expiration (in milliseconds).
  116. --jdbc-lock-renew-period=<jdbcLockRenewPeriod>
  117. Lock Renew Period (in milliseconds).
  118. --jdbc-message-table-name=<jdbcMessages>
  119. Name of the jdbc messages table.
  120. --jdbc-network-timeout=<jdbcNetworkTimeout>
  121. Network timeout (in milliseconds).
  122. --jdbc-node-manager-table-name=<jdbcNodeManager>
  123. Name of the jdbc node manager table.
  124. --jdbc-page-store-table-name=<jdbcPageStore>
  125. Name of the page store messages table.
  126. --journal-device-block-size=<journalDeviceBlockSize>
  127. The block size of the journal's storage device.
  128. Default: 4096.
  129. --journal-retention=<retentionDays>
  130. Configure journal retention in days. If > 0 then
  131. enable journal-retention-directory from broker.
  132. xml allowing replay options.
  133. --journal-retention-max-bytes=<retentionMaxBytes>
  134. Maximum number of bytes to keep in the retention
  135. directory.
  136. --linux, --cygwin Force Linux or Cygwin script creation. Default:
  137. based on your actual system.
  138. --mapped Set the journal as mapped.
  139. --max-hops=<maxHops> Number of hops on the cluster configuration.
  140. --message-load-balancing=<messageLoadBalancing>
  141. Message load balancing policy for cluster.
  142. Default: ON_DEMAND. Valid values: ON_DEMAND,
  143. STRICT, OFF, OFF_WITH_REDISTRIBUTION.
  144. --name=<name> The name of the broker. Default: same as host name.
  145. --nio Set the journal as nio.
  146. --no-amqp-acceptor Disable the AMQP specific acceptor.
  147. --no-autocreate Disable auto creation for addresses & queues.
  148. --no-autotune Disable auto tuning of the journal-buffer-timeout
  149. in broker.xml.
  150. --no-fsync Disable usage of fdatasync (channel.force(false)
  151. from Java NIO) on the journal.
  152. --no-hornetq-acceptor Disable the HornetQ specific acceptor.
  153. --no-mqtt-acceptor Disable the MQTT specific acceptor.
  154. --no-stomp-acceptor Disable the STOMP specific acceptor.
  155. --no-web Whether to omit the web-server definition from
  156. bootstrap.xml.
  157. --paging Page messages to disk when address becomes full.
  158. Opposite of --blocking. Default: true.
  159. --password=<password> The user's password. Default: input.
  160. --ping=<ping> A comma separated string to be passed on to the
  161. broker config as network-check-list. The broker
  162. will shutdown when all these addresses are
  163. unreachable.
  164. --port-offset=<portOffset>
  165. How much to off-set the ports of every acceptor.
  166. --queues=<queues> A comma separated list of queues with the option
  167. to specify a routing type, e.g. --queues
  168. myQueue1,myQueue2:multicast. Routing-type
  169. default: anycast.
  170. --relax-jolokia Disable strict checking in jolokia-access.xml.
  171. --replicated Enable broker replication.
  172. --require-login Require security credentials from users for
  173. connection. Opposite of --allow-anonymous.
  174. --role=<role> The name for the role created. Default: amq.
  175. --security-manager=<securityManager>
  176. Which security manager to use - jaas or basic.
  177. Default: jaas.
  178. --shared-store Enable broker shared store.
  179. --silent Disable all the inputs, and make a best guess for
  180. any required input.
  181. --slave Deprecated for removal. Use 'backup' instead.
  182. --ssl-key=<sslKey> Embedded web server's key store path.
  183. --ssl-key-password=<sslKeyPassword>
  184. The key store's password.
  185. --ssl-trust=<sslTrust> The trust store path in case of client
  186. authentication.
  187. --ssl-trust-password=<sslTrustPassword>
  188. The trust store's password.
  189. --staticCluster, --static-cluster=<staticNode>
  190. Cluster node connectors list separated by comma, e.
  191. g. "tcp://server:61616,tcp://server2:61616,tcp:
  192. //server3:61616".
  193. --support-advisory Support advisory messages for the OpenWire
  194. protocol.
  195. --suppress-internal-management-objects
  196. Do not register any advisory addresses/queues for
  197. the OpenWire protocol with the broker's
  198. management service.
  199. --use-client-auth Require client certificate authentication when
  200. connecting to the embedded web server.
  201. --user=<user> The username. Default: input.
  202. --verbose Print additional information.
  203. --windows Force Windows script creation. Default: based on
  204. your actual system.

Some of these options may be mandatory in certain configurations and the system may ask you for additional input, e.g.:

  1. $ ./artemis create /usr/server
  2. Creating ActiveMQ Artemis instance at: /usr/server
  3. --user:
  4. What is the default username?
  5. admin
  6. --password: is mandatory with this configuration:
  7. What is the default password?
  8. --allow-anonymous | --require-login:
  9. Allow anonymous access?, valid values are Y, N, True, False
  10. y
  11. Auto tuning journal ...
  12. done! Your system can make 250 writes per millisecond, your journal-buffer-timeout will be 4000
  13. You can now start the broker by executing:
  14. "/usr/server" run
  15. Or you can run the broker in the background using:
  16. "/usr/server" start

3. Starting and Stopping a Broker Instance

Assuming you created the broker instance under /var/lib/mybroker all you need to do start running the broker instance is execute:

  1. /var/lib/mybroker/bin/artemis run

To stop the Apache ActiveMQ Artemis instance you will use the same artemis script, but with the stop argument. Example:

  1. /var/lib/mybroker/bin/artemis stop

Please note that Apache ActiveMQ Artemis requires a Java 11 or later.

By default the etc/bootstrap.xml configuration is used. The configuration can be changed e.g. by running ./artemis run -- xml:path/to/bootstrap.xml or another config of your choosing.

Environment variables are used to provide ease of changing ports, hosts and data directories used and can be found in etc/artemis.profile on linux and etc\artemis.profile.cmd on Windows.

4. Configuration Files

These are the files you’re likely to find in the etc directory of a default broker instance with a short explanation of what they configure. Scroll down further for additional details as appropriate.

artemis.profile

system properties and JVM arguments (e.g. Xmx, Xms, etc.)

artemis-roles.properties

user/role mapping for the default properties-based JAAS login module

artemis-users.properties

user/password for the default properties-based JAAS login module

bootstrap.xml

embedded web server, security, location of broker.xml

broker.xml

core broker configuration, e.g. acceptors, addresses, queues, diverts, clustering; full reference

jolokia-access.xml

security for Jolokia, specifically Cross-Origin Resource Sharing (CORS)

log4j2.properties

logging config like levels, log file locations, etc.

login.config

standard Java configuration for JAAS security

management.xml

remote connectivity and security for JMX MBeans

4.1. Bootstrap Configuration File

The bootstrap.xml file is very simple. Let’s take a look at an example:

  1. <broker xmlns="http://activemq.apache.org/schema">
  2. <jaas-security domain="activemq"/>
  3. <server configuration="file:/path/to/broker.xml"/>
  4. <web path="web">
  5. <binding uri="http://localhost:8161">
  6. <app url="activemq-branding" war="activemq-branding.war"/>
  7. <app url="artemis-plugin" war="artemis-plugin.war"/>
  8. <app url="console" war="console.war"/>
  9. </binding>
  10. </web>
  11. </broker>

jaas-security

Configures JAAS-based security for the server. The domain attribute refers to the relevant login module entry in login.config. If different behavior is needed then a custom security manager can be configured by replacing jaas-security with security-manager. See the “Custom Security Manager” section in the security chapter for more details.

server

Instantiates a core server using the configuration file from the configuration attribute. This is the main broker POJO necessary to do all the real messaging work.

web

Configures an embedded web server for things like the admin console.

4.2. Broker configuration file

The configuration for the Apache ActiveMQ Artemis core broker is contained in broker.xml.

There are many attributes which you can configure for Apache ActiveMQ Artemis. In most cases the defaults will do fine, in fact every attribute can be defaulted which means a file with a single empty configuration element is a valid configuration file. The different configuration will be explained throughout the manual or you can refer to the configuration reference here.

5. Other Use-Cases

5.1. System Property Substitution

It is possible to use system property substitution in all the configuration files. by replacing a value with the name of a system property. Here is an example of this with a connector configuration:

  1. <connector name="netty">tcp://${activemq.remoting.netty.host:localhost}:${activemq.remoting.netty.port:61616}</connector>

Here you can see we have replaced 2 values with system properties activemq.remoting.netty.host and activemq.remoting.netty.port. These values will be replaced by the value found in the system property if there is one, if not they default back to localhost or 61616 respectively. It is also possible to not supply a default (i.e. ${activemq.remoting.netty.host}), however the system property must be supplied in that case.

5.2. Windows Server

On windows you will have the option to run ActiveMQ Artemis as a service. Just use the following command to install it:

  1. $ ./artemis-service.exe install

The create process should give you a hint of the available commands available for the artemis-service.exe

5.3. Adding Bootstrap Dependencies

Bootstrap dependencies like logging handlers must be accessible by the log manager at boot time. Package the dependency in a jar and put it on the boot classpath before of log manager jar. This can be done appending the jar at the variable JAVA_ARGS, defined in artemis.profile, with the option -Xbootclasspath/a.

the environment variable JAVA_ARGS_APPEND can be used to append or override options.

5.4. Adding Runtime Dependencies

Runtime dependencies like transformers, broker plugins, JDBC drivers, password decoders, etc. must be accessible by the broker at runtime. Package the dependency in a jar, and put it on the broker’s classpath. This can be done by placing the jar file in the lib directory of the broker distribution itself, by placing the jar file in the lib directory of the broker instance, by setting the system property artemis.extra.libs with the directory that contains the jar file, or by setting the environment variable ARTEMIS_EXTRA_LIBS with the directory that contains the jar file, A broker instance does not have a lib directory by default so it may need to be created. It should be on the “top” level with the bin, data, log, etc. directories. The system property artemis.extra.libs is a comma separated list of directories that contains jar files, i.e.

  1. -Dartemis.extra.libs=/usr/local/share/java/lib1,/usr/local/share/java/lib2

The environment variable ARTEMIS_EXTRA_LIBS is a comma separated list of directories that contains jar files and is ignored if the system property artemis.extra.libs is defined, i.e.

  1. export ARTEMIS_EXTRA_LIBS=/usr/local/share/java/lib1,/usr/local/share/java/lib2

5.5. Library Path

If you’re using the Asynchronous IO Journal on Linux, you need to specify java.library.path as a property on your Java options. This is done automatically in the scripts.

If you don’t specify java.library.path at your Java options then the JVM will use the environment variable LD_LIBRARY_PATH.

You will need to make sure libaio is installed on Linux. For more information refer to the libaio chapter.