Using the Server

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

Installation

The following highlights some important folders on the distribution:

  1. |___ bin
  2. |
  3. |___ examples
  4. | |___ common
  5. | |___ features
  6. | |___ perf
  7. | |___ protocols
  8. |
  9. |___ lib
  10. | |___ client
  11. |
  12. |___ schema
  13. |
  14. |___ web
  15. |___ api
  16. |___ hacking-guide
  17. |___ migration-guide
  18. |___ user-manual
  • bin - binaries and scripts needed to run ActiveMQ Artemis.

  • examples - All manner of examples. Please refer to the examples chapter for details on how to run them.

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

  • api - The api documentation is placed under the web folder.

  • user-manual - The user manual is placed under the web folder.

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:

  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.

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. NAME
  3. artemis create - creates a new broker instance
  4. SYNOPSIS
  5. artemis create [--addresses <addresses>] [--aio] [--allow-anonymous]
  6. [--autocreate] [--blocking] [--cluster-password <clusterPassword>]
  7. [--cluster-user <clusterUser>] [--clustered] [--data <data>]
  8. [--default-port <defaultPort>] [--disable-persistence]
  9. [--encoding <encoding>] [--etc <etc>] [--failover-on-shutdown] [--force]
  10. [--global-max-size <globalMaxSize>] [--home <home>] [--host <host>]
  11. [--http-host <httpHost>] [--http-port <httpPort>]
  12. [--java-options <javaOptions>] [--jdbc]
  13. [--jdbc-bindings-table-name <jdbcBindings>]
  14. [--jdbc-connection-url <jdbcURL>]
  15. [--jdbc-driver-class-name <jdbcClassName>]
  16. [--jdbc-large-message-table-name <jdbcLargeMessages>]
  17. [--jdbc-lock-expiration <jdbcLockExpiration>]
  18. [--jdbc-lock-renew-period <jdbcLockRenewPeriod>]
  19. [--jdbc-message-table-name <jdbcMessages>]
  20. [--jdbc-network-timeout <jdbcNetworkTimeout>]
  21. [--jdbc-node-manager-table-name <jdbcNodeManager>]
  22. [--jdbc-page-store-table-name <jdbcPageStore>]
  23. [--journal-device-block-size <journalDeviceBlockSize>] [--mapped]
  24. [--max-hops <maxHops>] [--message-load-balancing <messageLoadBalancing>]
  25. [--name <name>] [--nio] [--no-amqp-acceptor] [--no-autocreate]
  26. [--no-autotune] [--no-fsync] [--no-hornetq-acceptor]
  27. [--no-mqtt-acceptor] [--no-stomp-acceptor] [--no-web] [--paging]
  28. [--password <password>] [--ping <ping>] [--port-offset <portOffset>]
  29. [--queues <queues>] [--relax-jolokia] [--replicated] [--require-login]
  30. [--role <role>] [--security-manager <securityManager>] [--shared-store]
  31. [--silent] [--slave] [--ssl-key <sslKey>]
  32. [--ssl-key-password <sslKeyPassword>] [--ssl-trust <sslTrust>]
  33. [--ssl-trust-password <sslTrustPassword>] [--staticCluster <staticNode>]
  34. [--use-client-auth] [--user <user>] [--verbose] [--] <directory>
  35. OPTIONS
  36. --addresses <addresses>
  37. Comma separated list of addresses
  38. --aio
  39. Sets the journal as asyncio.
  40. --allow-anonymous
  41. Enables anonymous configuration on security, opposite of
  42. --require-login (Default: input)
  43. --autocreate
  44. Auto create addresses. (default: true)
  45. --blocking
  46. Block producers when address becomes full, opposite of --paging
  47. (Default: false)
  48. --cluster-password <clusterPassword>
  49. The cluster password to use for clustering. (Default: input)
  50. --cluster-user <clusterUser>
  51. The cluster user to use for clustering. (Default: input)
  52. --clustered
  53. Enable clustering
  54. --data <data>
  55. Directory where ActiveMQ data are stored. Paths can be absolute or
  56. relative to artemis.instance directory ('data' by default)
  57. --default-port <defaultPort>
  58. The port number to use for the main 'artemis' acceptor (Default:
  59. 61616)
  60. --disable-persistence
  61. Disable message persistence to the journal
  62. --encoding <encoding>
  63. The encoding that text files should use
  64. --etc <etc>
  65. Directory where ActiveMQ configuration is located. Paths can be
  66. absolute or relative to artemis.instance directory ('etc' by
  67. default)
  68. --failover-on-shutdown
  69. Valid for shared store: will shutdown trigger a failover? (Default:
  70. false)
  71. --force
  72. Overwrite configuration at destination directory
  73. --global-max-size <globalMaxSize>
  74. Maximum amount of memory which message data may consume (Default:
  75. Undefined, half of the system's memory)
  76. --home <home>
  77. Directory where ActiveMQ Artemis is installed
  78. --host <host>
  79. The host name of the broker (Default: 0.0.0.0 or input if clustered)
  80. --http-host <httpHost>
  81. The host name to use for embedded web server (Default: localhost)
  82. --http-port <httpPort>
  83. The port number to use for embedded web server (Default: 8161)
  84. --java-options <javaOptions>
  85. Extra java options to be passed to the profile
  86. --jdbc
  87. It will activate jdbc
  88. --jdbc-bindings-table-name <jdbcBindings>
  89. Name of the jdbc bindigns table
  90. --jdbc-connection-url <jdbcURL>
  91. The connection used for the database
  92. --jdbc-driver-class-name <jdbcClassName>
  93. JDBC driver classname
  94. --jdbc-large-message-table-name <jdbcLargeMessages>
  95. Name of the large messages table
  96. --jdbc-lock-expiration <jdbcLockExpiration>
  97. Lock expiration
  98. --jdbc-lock-renew-period <jdbcLockRenewPeriod>
  99. Lock Renew Period
  100. --jdbc-message-table-name <jdbcMessages>
  101. Name of the jdbc messages table
  102. --jdbc-network-timeout <jdbcNetworkTimeout>
  103. Network timeout
  104. --jdbc-node-manager-table-name <jdbcNodeManager>
  105. Name of the jdbc node manager table
  106. --jdbc-page-store-table-name <jdbcPageStore>
  107. Name of the page store messages table
  108. --journal-device-block-size <journalDeviceBlockSize>
  109. The block size by the device, default at 4096.
  110. --mapped
  111. Sets the journal as mapped.
  112. --max-hops <maxHops>
  113. Number of hops on the cluster configuration
  114. --message-load-balancing <messageLoadBalancing>
  115. Load balancing policy on cluster. [ON_DEMAND (default) | STRICT |
  116. OFF]
  117. --name <name>
  118. The name of the broker (Default: same as host)
  119. --nio
  120. Sets the journal as nio.
  121. --no-amqp-acceptor
  122. Disable the AMQP specific acceptor.
  123. --no-autocreate
  124. Disable Auto create addresses.
  125. --no-autotune
  126. Disable auto tuning on the journal.
  127. --no-fsync
  128. Disable usage of fdatasync (channel.force(false) from java nio) on
  129. the journal
  130. --no-hornetq-acceptor
  131. Disable the HornetQ specific acceptor.
  132. --no-mqtt-acceptor
  133. Disable the MQTT specific acceptor.
  134. --no-stomp-acceptor
  135. Disable the STOMP specific acceptor.
  136. --no-web
  137. Remove the web-server definition from bootstrap.xml
  138. --paging
  139. Page messages to disk when address becomes full, opposite of
  140. --blocking (Default: true)
  141. --password <password>
  142. The user's password (Default: input)
  143. --ping <ping>
  144. A comma separated string to be passed on to the broker config as
  145. network-check-list. The broker will shutdown when all these
  146. addresses are unreachable.
  147. --port-offset <portOffset>
  148. Off sets the ports of every acceptor
  149. --queues <queues>
  150. Comma separated list of queues with the option to specify a routing
  151. type. (ex: --queues myqueue,mytopic:multicast)
  152. --relax-jolokia
  153. disable strict checking on jolokia-access.xml
  154. --replicated
  155. Enable broker replication
  156. --require-login
  157. This will configure security to require user / password, opposite of
  158. --allow-anonymous
  159. --role <role>
  160. The name for the role created (Default: amq)
  161. --security-manager <securityManager>
  162. Which security manager to use - jaas or basic (Default: jaas)
  163. --shared-store
  164. Enable broker shared store
  165. --silent
  166. It will disable all the inputs, and it would make a best guess for
  167. any required input
  168. --slave
  169. Valid for shared store or replication: this is a slave server?
  170. --ssl-key <sslKey>
  171. The key store path for embedded web server
  172. --ssl-key-password <sslKeyPassword>
  173. The key store password
  174. --ssl-trust <sslTrust>
  175. The trust store path in case of client authentication
  176. --ssl-trust-password <sslTrustPassword>
  177. The trust store password
  178. --staticCluster <staticNode>
  179. Cluster node connectors list, separated by comma: Example
  180. "tcp://server:61616,tcp://server2:61616,tcp://server3:61616"
  181. --use-client-auth
  182. If the embedded server requires client authentication
  183. --user <user>
  184. The username (Default: input)
  185. --verbose
  186. Adds more information on the execution
  187. --
  188. This option can be used to separate command-line options from the
  189. list of argument, (useful when arguments might be mistaken for
  190. command-line options
  191. <directory>
  192. The instance directory to hold the broker's configuration and data.
  193. Path must be writable.

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: /user/server
  3. --user: is a mandatory property!
  4. Please provide the default username:
  5. admin
  6. --password: is mandatory with this configuration:
  7. Please provide the default password:
  8. --allow-anonymous | --require-login: is a mandatory property!
  9. Allow anonymous access?, valid values are Y,N,True,False
  10. y
  11. Auto tuning journal ...
  12. done! Your system can make 0.34 writes per millisecond, your journal-buffer-timeout will be 2956000
  13. You can now start the broker by executing:
  14. "/user/server/bin/artemis" run
  15. Or you can run the broker in the background using:
  16. "/user/server/bin/artemis-service" start

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

Now that the broker is running, you can optionally run some of the included examples to verify the broker is running properly.

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

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.

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.

Bootstrap configuration file

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

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

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.

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.

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

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.

Adding Runtime Dependencies

Runtime dependencies like diverts, 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 or in the lib directory of the broker instance. 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.