blob: fb52a3eaf479f8d9f755d58e3825a22fe151e044 [file] [log] [blame]
<!DOCTYPE HTML>
<html lang="" >
<head>
<title>Management ยท ActiveMQ Artemis Documentation</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="generator" content="GitBook 3.1.1">
<link rel="stylesheet" href="gitbook/style.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="management-console.html" />
<link rel="prev" href="pre-acknowledge.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="chapter " data-level="1.1" data-path="./">
<a href="./">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="notice.html">
<a href="notice.html">
Legal Notice
</a>
</li>
<li class="chapter " data-level="1.3" data-path="preface.html">
<a href="preface.html">
Preface
</a>
</li>
<li class="chapter " data-level="1.4" data-path="project-info.html">
<a href="project-info.html">
Project Info
</a>
</li>
<li class="chapter " data-level="1.5" data-path="versions.html">
<a href="versions.html">
Versions
</a>
</li>
<li class="chapter " data-level="1.6" data-path="messaging-concepts.html">
<a href="messaging-concepts.html">
Messaging Concepts
</a>
</li>
<li class="chapter " data-level="1.7" data-path="architecture.html">
<a href="architecture.html">
Architecture
</a>
</li>
<li class="chapter " data-level="1.8" data-path="using-server.html">
<a href="using-server.html">
Using the Server
</a>
</li>
<li class="chapter " data-level="1.9" data-path="upgrading.html">
<a href="upgrading.html">
Upgrading
</a>
</li>
<li class="chapter " data-level="1.10" data-path="address-model.html">
<a href="address-model.html">
Address Model
</a>
</li>
<li class="chapter " data-level="1.11" data-path="protocols-interoperability.html">
<a href="protocols-interoperability.html">
Protocols and Interoperability
</a>
</li>
<li class="chapter " data-level="1.12" data-path="amqp.html">
<a href="amqp.html">
AMQP
</a>
</li>
<li class="chapter " data-level="1.13" data-path="mqtt.html">
<a href="mqtt.html">
MQTT
</a>
</li>
<li class="chapter " data-level="1.14" data-path="stomp.html">
<a href="stomp.html">
STOMP
</a>
</li>
<li class="chapter " data-level="1.15" data-path="openwire.html">
<a href="openwire.html">
OpenWire
</a>
</li>
<li class="chapter " data-level="1.16" data-path="core.html">
<a href="core.html">
Core
</a>
</li>
<li class="chapter " data-level="1.17" data-path="jms-core-mapping.html">
<a href="jms-core-mapping.html">
Mapping JMS Concepts to the Core API
</a>
</li>
<li class="chapter " data-level="1.18" data-path="using-jms.html">
<a href="using-jms.html">
Using JMS
</a>
</li>
<li class="chapter " data-level="1.19" data-path="client-classpath.html">
<a href="client-classpath.html">
The Client Classpath
</a>
</li>
<li class="chapter " data-level="1.20" data-path="examples.html">
<a href="examples.html">
Examples
</a>
</li>
<li class="chapter " data-level="1.21" data-path="wildcard-routing.html">
<a href="wildcard-routing.html">
Routing Messages With Wild Cards
</a>
</li>
<li class="chapter " data-level="1.22" data-path="wildcard-syntax.html">
<a href="wildcard-syntax.html">
Wildcard Syntax
</a>
</li>
<li class="chapter " data-level="1.23" data-path="filter-expressions.html">
<a href="filter-expressions.html">
Filter Expressions
</a>
</li>
<li class="chapter " data-level="1.24" data-path="persistence.html">
<a href="persistence.html">
Persistence
</a>
</li>
<li class="chapter " data-level="1.25" data-path="configuring-transports.html">
<a href="configuring-transports.html">
Configuring Transports
</a>
</li>
<li class="chapter " data-level="1.26" data-path="config-reload.html">
<a href="config-reload.html">
Configuration Reload
</a>
</li>
<li class="chapter " data-level="1.27" data-path="connection-ttl.html">
<a href="connection-ttl.html">
Detecting Dead Connections
</a>
</li>
<li class="chapter " data-level="1.28" data-path="slow-consumers.html">
<a href="slow-consumers.html">
Detecting Slow Consumers
</a>
</li>
<li class="chapter " data-level="1.29" data-path="network-isolation.html">
<a href="network-isolation.html">
Avoiding Network Isolation
</a>
</li>
<li class="chapter " data-level="1.30" data-path="critical-analysis.html">
<a href="critical-analysis.html">
Detecting Broker Issues (Critical Analysis)
</a>
</li>
<li class="chapter " data-level="1.31" data-path="transaction-config.html">
<a href="transaction-config.html">
Resource Manager Configuration
</a>
</li>
<li class="chapter " data-level="1.32" data-path="flow-control.html">
<a href="flow-control.html">
Flow Control
</a>
</li>
<li class="chapter " data-level="1.33" data-path="send-guarantees.html">
<a href="send-guarantees.html">
Guarantees of sends and commits
</a>
</li>
<li class="chapter " data-level="1.34" data-path="undelivered-messages.html">
<a href="undelivered-messages.html">
Message Redelivery and Undelivered Messages
</a>
</li>
<li class="chapter " data-level="1.35" data-path="message-expiry.html">
<a href="message-expiry.html">
Message Expiry
</a>
</li>
<li class="chapter " data-level="1.36" data-path="large-messages.html">
<a href="large-messages.html">
Large Messages
</a>
</li>
<li class="chapter " data-level="1.37" data-path="paging.html">
<a href="paging.html">
Paging
</a>
</li>
<li class="chapter " data-level="1.38" data-path="scheduled-messages.html">
<a href="scheduled-messages.html">
Scheduled Messages
</a>
</li>
<li class="chapter " data-level="1.39" data-path="last-value-queues.html">
<a href="last-value-queues.html">
Last-Value Queues
</a>
</li>
<li class="chapter " data-level="1.40" data-path="ring-queues.html">
<a href="ring-queues.html">
Ring Queues
</a>
</li>
<li class="chapter " data-level="1.41" data-path="retroactive-addresses.html">
<a href="retroactive-addresses.html">
Retroactive Addresses
</a>
</li>
<li class="chapter " data-level="1.42" data-path="exclusive-queues.html">
<a href="exclusive-queues.html">
Exclusive Queues
</a>
</li>
<li class="chapter " data-level="1.43" data-path="message-grouping.html">
<a href="message-grouping.html">
Message Grouping
</a>
</li>
<li class="chapter " data-level="1.44" data-path="consumer-priority.html">
<a href="consumer-priority.html">
Consumer Priority
</a>
</li>
<li class="chapter " data-level="1.45" data-path="pre-acknowledge.html">
<a href="pre-acknowledge.html">
Extra Acknowledge Modes
</a>
</li>
<li class="chapter active" data-level="1.46" data-path="management.html">
<a href="management.html">
Management
</a>
</li>
<li class="chapter " data-level="1.47" data-path="management-console.html">
<a href="management-console.html">
Management Console
</a>
</li>
<li class="chapter " data-level="1.48" data-path="metrics.html">
<a href="metrics.html">
Metrics
</a>
</li>
<li class="chapter " data-level="1.49" data-path="security.html">
<a href="security.html">
Security
</a>
</li>
<li class="chapter " data-level="1.50" data-path="masking-passwords.html">
<a href="masking-passwords.html">
Masking Passwords
</a>
</li>
<li class="chapter " data-level="1.51" data-path="broker-plugins.html">
<a href="broker-plugins.html">
Broker Plugins
</a>
</li>
<li class="chapter " data-level="1.52" data-path="resource-limits.html">
<a href="resource-limits.html">
Resource Limits
</a>
</li>
<li class="chapter " data-level="1.53" data-path="jms-bridge.html">
<a href="jms-bridge.html">
The JMS Bridge
</a>
</li>
<li class="chapter " data-level="1.54" data-path="client-reconnection.html">
<a href="client-reconnection.html">
Client Reconnection and Session Reattachment
</a>
</li>
<li class="chapter " data-level="1.55" data-path="diverts.html">
<a href="diverts.html">
Diverting and Splitting Message Flows
</a>
</li>
<li class="chapter " data-level="1.56" data-path="core-bridges.html">
<a href="core-bridges.html">
Core Bridges
</a>
</li>
<li class="chapter " data-level="1.57" data-path="transformers.html">
<a href="transformers.html">
Transformers
</a>
</li>
<li class="chapter " data-level="1.58" data-path="duplicate-detection.html">
<a href="duplicate-detection.html">
Duplicate Message Detection
</a>
</li>
<li class="chapter " data-level="1.59" data-path="clusters.html">
<a href="clusters.html">
Clusters
</a>
</li>
<li class="chapter " data-level="1.60" data-path="federation.html">
<a href="federation.html">
Federation
</a>
<ul class="articles">
<li class="chapter " data-level="1.60.1" data-path="federation-address.html">
<a href="federation-address.html">
Address Federation
</a>
</li>
<li class="chapter " data-level="1.60.2" data-path="federation-queue.html">
<a href="federation-queue.html">
Queue Federation
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.61" data-path="ha.html">
<a href="ha.html">
High Availability and Failover
</a>
</li>
<li class="chapter " data-level="1.62" data-path="graceful-shutdown.html">
<a href="graceful-shutdown.html">
Graceful Server Shutdown
</a>
</li>
<li class="chapter " data-level="1.63" data-path="libaio.html">
<a href="libaio.html">
Libaio Native Libraries
</a>
</li>
<li class="chapter " data-level="1.64" data-path="thread-pooling.html">
<a href="thread-pooling.html">
Thread management
</a>
</li>
<li class="chapter " data-level="1.65" data-path="web-server.html">
<a href="web-server.html">
Embedded Web Server
</a>
</li>
<li class="chapter " data-level="1.66" data-path="logging.html">
<a href="logging.html">
Logging
</a>
</li>
<li class="chapter " data-level="1.67" data-path="rest.html">
<a href="rest.html">
REST Interface
</a>
</li>
<li class="chapter " data-level="1.68" data-path="embedding-activemq.html">
<a href="embedding-activemq.html">
Embedding the Broker
</a>
</li>
<li class="chapter " data-level="1.69" data-path="karaf.html">
<a href="karaf.html">
Apache Karaf
</a>
</li>
<li class="chapter " data-level="1.70" data-path="tomcat.html">
<a href="tomcat.html">
Apache Tomcat
</a>
</li>
<li class="chapter " data-level="1.71" data-path="spring-integration.html">
<a href="spring-integration.html">
Spring Integration
</a>
</li>
<li class="chapter " data-level="1.72" data-path="cdi-integration.html">
<a href="cdi-integration.html">
CDI Integration
</a>
</li>
<li class="chapter " data-level="1.73" data-path="intercepting-operations.html">
<a href="intercepting-operations.html">
Intercepting Operations
</a>
</li>
<li class="chapter " data-level="1.74" data-path="data-tools.html">
<a href="data-tools.html">
Data Tools
</a>
</li>
<li class="chapter " data-level="1.75" data-path="maven-plugin.html">
<a href="maven-plugin.html">
Maven Plugin
</a>
</li>
<li class="chapter " data-level="1.76" data-path="unit-testing.html">
<a href="unit-testing.html">
Unit Testing
</a>
</li>
<li class="chapter " data-level="1.77" data-path="perf-tuning.html">
<a href="perf-tuning.html">
Troubleshooting and Performance Tuning
</a>
</li>
<li class="chapter " data-level="1.78" data-path="configuration-index.html">
<a href="configuration-index.html">
Configuration Reference
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="." >Management</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h1 id="management">Management</h1>
<p>Apache ActiveMQ Artemis has an extensive <em>management API</em> that allows a user to
modify a server configuration, create new resources (e.g. addresses and
queues), inspect these resources (e.g. how many messages are currently held in
a queue) and interact with it (e.g. to remove messages from a queue). Apache
ActiveMQ Artemis also allows clients to subscribe to management notifications.</p>
<p>There are four ways to access Apache ActiveMQ Artemis management API:</p>
<ul>
<li><p>Using JMX -- <em>JMX</em> is the standard way to manage Java applications</p>
</li>
<li><p>Using Jolokia -- Jolokia exposes the JMX API of an application through a
<em>REST interface</em></p>
</li>
<li><p>Using the Core Client -- management operations are sent to Apache ActiveMQ
Artemis server using <em>Core Client messages</em></p>
</li>
<li><p>Using any JMS Client -- management operations are sent to Apache ActiveMQ
Artemis server using <em>JMS Client messages</em></p>
</li>
</ul>
<p>Although there are four different ways to manage Apache ActiveMQ Artemis, each
API supports the same functionality. If it is possible to manage a resource
using JMX it is also possible to achieve the same result using Core messages.</p>
<p>Besides these four management interfaces, a <a href="management-console.html">Web Console</a>
and a Command Line <em>management utility</em> are also available to administrators of
ActiveMQ Artemis.</p>
<p>The choice depends on your requirements, your application settings, and your
environment to decide which way suits you best.</p>
<blockquote>
<p><strong>Note:</strong></p>
<p>In version 2 of Apache ActiveMQ Artemis the syntax used for MBean Object
names has changed significantly due to changes in the addressing scheme. See
the documentation for each individual resource for details on the new syntax.</p>
</blockquote>
<h2 id="the-management-api">The Management API</h2>
<p>Regardless of the way you <em>invoke</em> management operations, the management API is
the same.</p>
<p>For each <em>managed resource</em>, there exists a Java interface describing what
operations can be invoked for this type of resource.</p>
<p>To learn about available <em>management operations</em>, see the Javadoc for these
interfaces. They are located in the
<code>org.apache.activemq.artemis.api.core.management</code> package and they are named
with the word <code>Control</code> at the end.</p>
<p>The way to invoke management operations depends on whether JMX, Core messages,
or JMS messages are used.</p>
<h3 id="management-api">Management API</h3>
<p>For full details of the API please consult the Javadoc. In summary:</p>
<h4 id="server-management">Server Management</h4>
<p>The <code>ActiveMQServerControl</code> interface is the entry point for broker management.</p>
<ul>
<li><p>Listing, creating, deploying and destroying queues</p>
<p>A list of deployed queues can be retrieved using the <code>getQueueNames()</code>
method.</p>
<p>Queues can be created or destroyed using the management operations
<code>createQueue()</code> or <code>deployQueue()</code> or <code>destroyQueue()</code>.</p>
<p><code>createQueue</code> will fail if the queue already exists while <code>deployQueue</code> will
do nothing.</p>
</li>
<li><p>Listing and closing remote connections</p>
<p>Client&apos;s remote addresses can be retrieved using <code>listRemoteAddresses()</code>. It
is also possible to close the connections associated with a remote address
using the <code>closeConnectionsForAddress()</code> method.</p>
<p>Alternatively, connection IDs can be listed using <code>listConnectionIDs()</code> and
all the sessions for a given connection ID can be listed using
<code>listSessions()</code>.</p>
</li>
<li><p>Transaction heuristic operations</p>
<p>In case of a server crash, when the server restarts, it it possible that some
transaction requires manual intervention. The <code>listPreparedTransactions()</code>
method lists the transactions which are in the prepared states (the
transactions are represented as opaque Base64 Strings.) To commit or rollback a
given prepared transaction, the <code>commitPreparedTransaction()</code> or
<code>rollbackPreparedTransaction()</code> method can be used to resolve heuristic
transactions. Heuristically completed transactions can be listed using the
<code>listHeuristicCommittedTransactions()</code> and
<code>listHeuristicRolledBackTransactions</code> methods.</p>
</li>
<li><p>Enabling and resetting Message counters</p>
<p>Message counters can be enabled or disabled using the
<code>enableMessageCounters()</code> or <code>disableMessageCounters()</code> method. To reset
message counters, it is possible to invoke <code>resetAllMessageCounters()</code> and
<code>resetAllMessageCounterHistories()</code> methods.</p>
</li>
<li><p>Retrieving the server configuration and attributes</p>
<p>The <code>ActiveMQServerControl</code> exposes Apache ActiveMQ Artemis server
configuration through all its attributes (e.g. <code>getVersion()</code> method to
retrieve the server&apos;s version, etc.)</p>
</li>
<li><p>Listing, creating and destroying Core bridges and diverts</p>
<p>A list of deployed core bridges (resp. diverts) can be retrieved using the
<code>getBridgeNames()</code> (resp. <code>getDivertNames()</code>) method.</p>
<p>Core bridges (resp. diverts) can be created or destroyed using the management
operations <code>createBridge()</code> and <code>destroyBridge()</code> (resp. <code>createDivert()</code> and
<code>destroyDivert()</code>).</p>
</li>
<li><p>It is possible to stop the server and force failover to occur with any
currently attached clients.</p>
<p>To do this use the <code>forceFailover()</code> operation. </p>
<blockquote>
<p><strong>Note:</strong></p>
<p>Since this method actually stops the server you will probably receive some
sort of error depending on which management service you use to call it.</p>
</blockquote>
</li>
</ul>
<h4 id="address-management">Address Management</h4>
<p>Individual addresses can be managed using the <code>AddressControl</code> interface.</p>
<ul>
<li><p>Modifying roles and permissions for an address</p>
<p>You can add or remove roles associated to a queue using the <code>addRole()</code> or
<code>removeRole()</code> methods. You can list all the roles associated to the queue with
the <code>getRoles()</code> method</p>
</li>
<li><p>Pausing and resuming Address</p>
<p>The <code>AddressControl</code> can pause and resume an address and all the queues that
are bound to it. Newly added queue will be paused too until the address is resumed.
Thus all messages sent to the address will be recived but not delivered. When it is
resumed, delivering will occur again.</p>
</li>
</ul>
<h4 id="queue-management">Queue Management</h4>
<p>The bulk of the management API deals with queues. The <code>QueueControl</code> interface
defines the queue management operations.</p>
<p>Most of the management operations on queues take either a single message ID
(e.g. to remove a single message) or a filter (e.g. to expire all messages with
a given property.)</p>
<blockquote>
<p><strong>Note:</strong></p>
<p>Passing <code>null</code> or an empty string in the <code>filter</code> parameter means that the
management operation will be performed on <em>all messages</em> in a queue.</p>
</blockquote>
<ul>
<li><p>Expiring, sending to a dead letter address and moving messages</p>
<p>Messages can be expired from a queue by using the <code>expireMessages()</code> method.
If an expiry address is defined, messages will be sent to it, otherwise they
are discarded.</p>
<p>Messages can also be sent to a dead letter address with the
<code>sendMessagesToDeadLetterAddress()</code> method. It returns the number of messages
which are sent to the dead letter address. If a dead letter address is not
defined, message are removed from the queue and discarded.</p>
<p>Messages can also be moved from a queue to another queue by using the
<code>moveMessages()</code> method.</p>
</li>
<li><p>Listing and removing messages</p>
<p>Messages can be listed from a queue by using the <code>listMessages()</code> method
which returns an array of <code>Map</code>, one <code>Map</code> for each message.</p>
<p>Messages can also be removed from the queue by using the <code>removeMessages()</code>
method which returns a <code>boolean</code> for the single message ID variant or the
number of removed messages for the filter variant. The <code>removeMessages()</code>
method takes a <code>filter</code> argument to remove only filtered messages. Setting the
filter to an empty string will in effect remove all messages.</p>
</li>
<li><p>Counting messages</p>
<p>The number of messages in a queue is returned by the <code>getMessageCount()</code>
method. Alternatively, the <code>countMessages()</code> will return the number of messages
in the queue which <em>match a given filter</em>.</p>
</li>
<li><p>Changing message priority</p>
<p>The message priority can be changed by using the <code>changeMessagesPriority()</code>
method which returns a <code>boolean</code> for the single message ID variant or the
number of updated messages for the filter variant.</p>
</li>
<li><p>Message counters</p>
<p>Message counters can be listed for a queue with the <code>listMessageCounter()</code>
and <code>listMessageCounterHistory()</code> methods (see Message Counters section). The
message counters can also be reset for a single queue using the
<code>resetMessageCounter()</code> method.</p>
</li>
<li><p>Retrieving the queue attributes</p>
<p>The <code>QueueControl</code> exposes queue settings through its attributes (e.g.
<code>getFilter()</code> to retrieve the queue&apos;s filter if it was created with one,
<code>isDurable()</code> to know whether the queue is durable or not, etc.)</p>
</li>
<li><p>Pausing and resuming Queues</p>
<p>The <code>QueueControl</code> can pause and resume the underlying queue. When a queue is
paused, it will receive messages but will not deliver them. When it&apos;s resumed,
it&apos;ll begin delivering the queued messages, if any.</p>
</li>
</ul>
<h4 id="other-resources-management">Other Resources Management</h4>
<p>Apache ActiveMQ Artemis allows to start and stop its remote resources
(acceptors, diverts, bridges, etc.) so that a server can be taken off line for
a given period of time without stopping it completely (e.g. if other management
operations must be performed such as resolving heuristic transactions). These
resources are:</p>
<ul>
<li><p>Acceptors</p>
<p>They can be started or stopped using the <code>start()</code> or. <code>stop()</code> method on the
<code>AcceptorControl</code> interface. The acceptors parameters can be retrieved using
the <code>AcceptorControl</code> attributes (see <a href="configuring-transports.html">Understanding
Acceptors</a>)</p>
</li>
<li><p>Diverts</p>
<p>They can be started or stopped using the <code>start()</code> or <code>stop()</code> method on the
<code>DivertControl</code> interface. Diverts parameters can be retrieved using the
<code>DivertControl</code> attributes (see <a href="diverts.html">Diverting and Splitting Message
Flows)</a>)</p>
</li>
<li><p>Bridges</p>
<p>They can be started or stopped using the <code>start()</code> (resp. <code>stop()</code>) method on
the <code>BridgeControl</code> interface. Bridges parameters can be retrieved using the
<code>BridgeControl</code> attributes (see <a href="core-bridges.html">Core bridges</a>)</p>
</li>
<li><p>Broadcast groups</p>
<p>They can be started or stopped using the <code>start()</code> or <code>stop()</code> method on the
<code>BroadcastGroupControl</code> interface. Broadcast groups parameters can be retrieved
using the <code>BroadcastGroupControl</code> attributes (see <a href="clusters.html">Clusters</a>)</p>
</li>
<li><p>Cluster connections</p>
<p>They can be started or stopped using the <code>start()</code> or <code>stop()</code> method on the
<code>ClusterConnectionControl</code> interface. Cluster connections parameters can be
retrieved using the <code>ClusterConnectionControl</code> attributes (see
<a href="clusters.html">Clusters</a>)</p>
</li>
</ul>
<h2 id="using-management-via-jmx">Using Management Via JMX</h2>
<p>Apache ActiveMQ Artemis can be managed using
<a href="http://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html" target="_blank">JMX</a>.</p>
<p>The management API is exposed by Apache ActiveMQ Artemis using MBeans
interfaces. Apache ActiveMQ Artemis registers its resources with the domain
<code>org.apache.activemq.artemis</code>.</p>
<p>For example, the <code>ObjectName</code> to manage the anycast queue <code>exampleQueue</code> on the
address <code>exampleAddress</code> is:</p>
<pre><code>org.apache.activemq.artemis:broker=&lt;brokerName&gt;,component=addresses,address=&quot;exampleAddress&quot;,subcomponent=queues,routing-type=&quot;anycast&quot;,queue=&quot;exampleQueue&quot;
</code></pre><p>and the MBean is:</p>
<pre><code>org.apache.activemq.artemis.api.core.management.QueueControl
</code></pre><p>The MBean <code>ObjectName</code>&apos;s are built using the helper class
<code>org.apache.activemq.artemis.api.core.management.ObjectNameBuilder</code>. You can
also use <code>jconsole</code> to find the <code>ObjectName</code> of the MBean you want to manage.</p>
<p>Example usage of the <code>ObjectNameBuilder</code> to obtain <code>ActiveMQServerControl</code>&apos;s name:</p>
<pre><code class="lang-java">brokerName = <span class="hljs-string">&quot;0.0.0.0&quot;</span>; <span class="hljs-comment">// configured e.g. in broker.xml &lt;broker-name&gt; element</span>
objectNameBuilder = ObjectNameBuilder.create(ArtemisResolver.DEFAULT_DOMAIN, brokerName, <span class="hljs-keyword">true</span>);
serverObjectName = objectNameBuilder.getActiveMQServerObjectName()
</code></pre>
<p>Managing Apache ActiveMQ Artemis using JMX is identical to management of any
Java Applications using JMX. It can be done by reflection or by creating
proxies of the MBeans.</p>
<h3 id="configuring-jmx">Configuring JMX</h3>
<p>By default, JMX is enabled to manage Apache ActiveMQ Artemis. It can be
disabled by setting <code>jmx-management-enabled</code> to <code>false</code> in <code>broker.xml</code>:</p>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- false to disable JMX management for Apache ActiveMQ Artemis --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">jmx-management-enabled</span>&gt;</span>false<span class="hljs-tag">&lt;/<span class="hljs-name">jmx-management-enabled</span>&gt;</span>
</code></pre>
<h4 id="role-based-authorisation-for-jmx">Role Based Authorisation for JMX</h4>
<p>Although by default Artemis uses the Java Virtual Machine&apos;s <code>Platform
MBeanServer</code> this is guarded using role based authentication that leverages
Artemis&apos;s JAAS plugin support. This is configured via the <code>authorisation</code>
element in the <code>management.xml</code> configuration file and can be used to restrict
access to attributes and methods on mbeans.</p>
<p>There are 3 elements within the <code>authorisation</code> element, <code>whitelist</code>,
<code>default-access</code> and <code>role-access</code>, Lets discuss each in turn.</p>
<p>Whitelist contains a list of mBeans that will by pass the authentication, this
is typically used for any mbeans that are needed by the console to run etc. The
default configuration is:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">whitelist</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">entry</span> <span class="hljs-attr">domain</span>=<span class="hljs-string">&quot;hawtio&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">whitelist</span>&gt;</span>
</code></pre>
<p>This means that any mbean with the domain <code>hawtio</code> will be allowed access
without authorisation. for instance <code>hawtio:plugin=artemis</code>. You can also use
wildcards for the mBean properties so the following would also match.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">whitelist</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">entry</span> <span class="hljs-attr">domain</span>=<span class="hljs-string">&quot;hawtio&quot;</span> <span class="hljs-attr">key</span>=<span class="hljs-string">&quot;type=*&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">whitelist</span>&gt;</span>
</code></pre>
<p>The <code>role-access</code>defines how roles are mapped to particular mBeans and its
attributes and methods, the default configuration looks like:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">role-access</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">match</span> <span class="hljs-attr">domain</span>=<span class="hljs-string">&quot;org.apache.activemq.artemis&quot;</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;list*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;view,update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;get*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;view,update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;is*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;view,update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;set*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">match</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">role-access</span>&gt;</span>
</code></pre>
<p>This contains 1 match and will be applied to any mBean that has the domain
<code>org.apache.activemq.artemis</code>. Any access to any mBeans that have this domain
are controlled by the <code>access</code> elements which contain a method and a set of
roles. The method being invoked will be used to pick the closest matching
method and the roles for this will be applied for access. For instance if you
try the invoke a method called <code>listMessages</code> on an mBean with the
<code>org.apache.activemq.artemis</code> domain then this would match the <code>access</code> with
the method of <code>list*</code>. You could also explicitly configure this by using the
full method name, like so:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;listMessages&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;view,update,amq&quot;</span>/&gt;</span>
</code></pre>
<p>You can also match specific mBeans within a domain by adding a key attribute
that is used to match one of the properties on the mBean, like:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">match</span> <span class="hljs-attr">domain</span>=<span class="hljs-string">&quot;org.apache.activemq.artemis&quot;</span> <span class="hljs-attr">key</span>=<span class="hljs-string">&quot;subcomponent=queues&quot;</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;list*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;view,update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;get*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;view,update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;is*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;view,update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;set*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">match</span>&gt;</span>
</code></pre>
<p>You could also match a specific queue for instance:</p>
<pre><code>org.apache.activemq.artemis:broker=&lt;brokerName&gt;,component=addresses,address=&quot;exampleAddress&quot;,subcomponent=queues,routing-type=&quot;anycast&quot;,queue=&quot;exampleQueue&quot;
</code></pre><p>by configuring:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">match</span> <span class="hljs-attr">domain</span>=<span class="hljs-string">&quot;org.apache.activemq.artemis&quot;</span> <span class="hljs-attr">key</span>=<span class="hljs-string">&quot;queue=exampleQueue&quot;</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;list*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;view,update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;get*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;view,update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;is*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;view,update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;set*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">match</span>&gt;</span>
</code></pre>
<p>You can also use wildcards for the mBean properties so the following would
also match, allowing prefix match for the mBean properties.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">match</span> <span class="hljs-attr">domain</span>=<span class="hljs-string">&quot;org.apache.activemq.artemis&quot;</span> <span class="hljs-attr">key</span>=<span class="hljs-string">&quot;queue=example*&quot;</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;list*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;view,update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;get*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;view,update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;is*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;view,update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;set*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;update,amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">access</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;*&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;amq&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">match</span>&gt;</span>
</code></pre>
<p>In case of multiple matches, the exact matches have higher priority than the
wildcard matches and the longer wildcard matches have higher priority than the
shorter wildcard matches.</p>
<p>Access to JMX mBean attributes are converted to method calls so these are
controlled via the <code>set*</code>, <code>get*</code> and <code>is*</code>. The <code>*</code> access is the catch all
for everything other method that isn&apos;t specifically matched.</p>
<p>The <code>default-access</code> element is basically the catch all for every method call
that isn&apos;t handled via the <code>role-access</code> configuration. This has the same
semantics as a <code>match</code> element.</p>
<blockquote>
<p><strong>Note:</strong></p>
<p>If JMX is enabled, Apache ActiveMQ Artemis can <em>not</em> be managed locally using
<code>jconsole</code> when connecting as a local process, this is because jconsole does
not using any authentication when connecting this way. If you want to use
jconsole you will either have to disable authentication, by removing the
<code>authentication</code> element or enable remote access.</p>
</blockquote>
<h4 id="configuring-remote-jmx-access">Configuring remote JMX Access</h4>
<p>By default remote JMX access to Artemis is disabled for security reasons.</p>
<p>Artemis has a JMX agent which allows access to JMX mBeans remotely. This is
configured via the <code>connector</code> element in the <code>management.xml</code> configuration
file. To enable this you simply add the following xml:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">connector</span> <span class="hljs-attr">connector-port</span>=<span class="hljs-string">&quot;1099&quot;</span>/&gt;</span>
</code></pre>
<p>This exposes the agent remotely on the port 1099. If you were connecting via
jconsole you would connect as a remote process using the service url
<code>service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi</code> and an appropriate user
name and password.</p>
<p>You can also configure the connector using the following:</p>
<ul>
<li><p><code>connector-host</code></p>
<p>The host to expose the agent on.</p>
</li>
<li><p><code>connector-port</code></p>
<p>The port to expose the agent on.</p>
</li>
<li><p><code>rmi-registry-port</code></p>
<p>The port that the RMI registry binds to. If not set, the port is
always random. Set to avoid problems with remote JMX connections
tunnelled through firewall.</p>
</li>
<li><p><code>jmx-realm</code></p>
<p>The jmx realm to use for authentication, defaults to <code>activemq</code> to match the
JAAS configuration.</p>
</li>
<li><p><code>object-name</code></p>
<p>The object name to expose the remote connector on; default is
<code>connector:name=rmi</code>.</p>
</li>
<li><p><code>secured</code></p>
<p>Whether the connector is secured using SSL.</p>
</li>
<li><p><code>key-store-path</code></p>
<p>The location of the keystore.</p>
</li>
<li><p><code>key-store-password</code></p>
<p>The keystore password. This can be <a href="masking-passwords.html">masked</a>.</p>
</li>
<li><p><code>key-store-provider</code></p>
<p>The provider; <code>JKS</code> by default.</p>
</li>
<li><p><code>trust-store-path</code></p>
<p>The location of the truststore.</p>
</li>
<li><p><code>trust-store-password</code></p>
<p>The trustore password. This can be <a href="masking-passwords.html">masked</a>.</p>
</li>
<li><p><code>trust-store-provider</code></p>
<p>The provider; <code>JKS</code> by default.</p>
</li>
<li><p><code>password-codec</code></p>
<p>The fully qualified class name of the password codec to use. See the
<a href="masking-passwords.html">password masking</a> documentation for more details on
how this works.</p>
</li>
</ul>
<blockquote>
<p><strong>Note:</strong></p>
<p>It is important to note that the rmi registry will pick an ip address to bind
to, If you have a multi IP addresses/NICs present on the system then you can
choose the ip address to use by adding the following to artemis.profile
<code>-Djava.rmi.server.hostname=localhost</code></p>
<p><strong>Note:</strong></p>
<p>Remote connections using the default JVM Agent not enabled by default as
Artemis exposes the mBean Server via its own configuration. This is so
Artemis can leverage the JAAS authentication layer via JMX. If you want to
expose this then you will need to disable both the connector and the
authorisation by removing them from the <code>management.xml</code> configuration.
Please refer to <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html" target="_blank">Java Management
guide</a>
to configure the server for remote management (system properties must be set
in <code>artemis.profile</code>).</p>
</blockquote>
<p>By default, Apache ActiveMQ Artemis server uses the JMX domain
&quot;org.apache.activemq.artemis&quot;. To manage several Apache ActiveMQ Artemis
servers from the <em>same</em> MBeanServer, the JMX domain can be configured for each
individual Apache ActiveMQ Artemis server by setting <code>jmx-domain</code> in
<code>broker.xml</code>:</p>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- use a specific JMX domain for ActiveMQ Artemis MBeans --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">jmx-domain</span>&gt;</span>my.org.apache.activemq<span class="hljs-tag">&lt;/<span class="hljs-name">jmx-domain</span>&gt;</span>
</code></pre>
<h3 id="example">Example</h3>
<p>See the <a href="examples.html#jmx-management">JMX Management Example</a> which shows how to
use a remote connection to JMX and MBean proxies to manage Apache ActiveMQ
Artemis.</p>
<h3 id="exposing-jmx-using-jolokia">Exposing JMX using Jolokia</h3>
<p>The default Broker configuration ships with the <a href="https://jolokia.org" target="_blank">Jolokia</a>
HTTP agent deployed as a web application. Jolokia is a remote JMX-over-HTTP
bridge that exposes MBeans. For a full guide as to how to use it refer to
<a href="https://jolokia.org/documentation.html" target="_blank">Jolokia Documentation</a>, however a
simple example to query the broker&apos;s version would be to use a browser and go
to the URL
<a href="">http://username:password@localhost:8161/console/jolokia/read/org.apache.activemq.artemis:broker=&quot;0.0.0.0&quot;/Version</a>.</p>
<p>This would give you back something like the following:</p>
<pre><code>{&quot;request&quot;:{&quot;mbean&quot;:&quot;org.apache.activemq.artemis:broker=\&quot;0.0.0.0\&quot;&quot;,&quot;attribute&quot;:&quot;Version&quot;,&quot;type&quot;:&quot;read&quot;},&quot;value&quot;:&quot;2.0.0-SNAPSHOT&quot;,&quot;timestamp&quot;:1487017918,&quot;status&quot;:200}
</code></pre><h3 id="jmx-and-the-console">JMX and the Console</h3>
<p>The console that ships with Artemis uses Jolokia under the covers which in turn
uses JMX. This will use the authentication configuration in the
<code>management.xml</code> file as described in the previous section. This means that
when mBeans are accessed via the console the credentials used to log into the
console and the roles associated with them. By default access to the console is
only allow via users with the amq role. This is configured in the
<code>artemis.profile</code> via the system property <code>-Dhawtio.role=amq</code>. You can
configure multiple roles by changing this to <code>-Dhawtio.roles=amq,view,update</code>.</p>
<p>If a user doesn&apos;t have the correct role to invoke a specific operation then
this will display an authorisation exception in the console. </p>
<h2 id="using-management-message-api">Using Management Message API</h2>
<p>The management message API in ActiveMQ Artemis is accessed by sending Core
Client messages to a special address, the <em>management address</em>.</p>
<p><em>Management messages</em> are regular Core Client messages with well-known
properties that the server needs to understand to interact with the management
API:</p>
<ul>
<li><p>The name of the managed resource</p>
</li>
<li><p>The name of the management operation</p>
</li>
<li><p>The parameters of the management operation</p>
</li>
</ul>
<p>When such a management message is sent to the management address, Apache
ActiveMQ Artemis server will handle it, extract the information, invoke the
operation on the managed resources and send a <em>management reply</em> to the
management message&apos;s reply-to address (specified by
<code>ClientMessageImpl.REPLYTO_HEADER_NAME</code>).</p>
<p>A <code>ClientConsumer</code> can be used to consume the management reply and retrieve the
result of the operation (if any) stored in the reply&apos;s body. For portability,
results are returned as a <a href="https://json.org" target="_blank">JSON</a> String rather than Java
Serialization (the
<code>org.apache.activemq.artemis.api.core.management.ManagementHelper</code> can be used
to convert the JSON string to Java objects).</p>
<p>These steps can be simplified to make it easier to invoke management operations
using Core messages:</p>
<ol>
<li><p>Create a <code>ClientRequestor</code> to send messages to the management address and
receive replies</p>
</li>
<li><p>Create a <code>ClientMessage</code></p>
</li>
<li><p>Use the helper class
<code>org.apache.activemq.artemis.api.core.management.ManagementHelper</code> to fill
the message with the management properties</p>
</li>
<li><p>Send the message using the <code>ClientRequestor</code></p>
</li>
<li><p>Use the helper class
<code>org.apache.activemq.artemis.api.core.management.ManagementHelper</code> to
retrieve the operation result from the management reply.</p>
</li>
</ol>
<p>For example, to find out the number of messages in the queue <code>exampleQueue</code>:</p>
<pre><code class="lang-java">ClientSession session = ...
ClientRequestor requestor = <span class="hljs-keyword">new</span> ClientRequestor(session, <span class="hljs-string">&quot;activemq.management&quot;</span>);
ClientMessage message = session.createMessage(<span class="hljs-keyword">false</span>);
ManagementHelper.putAttribute(message, <span class="hljs-string">&quot;queue.exampleQueue&quot;</span>, <span class="hljs-string">&quot;messageCount&quot;</span>);
session.start();
ClientMessage reply = requestor.request(m);
<span class="hljs-keyword">int</span> count = (Integer) ManagementHelper.getResult(reply);
System.out.println(<span class="hljs-string">&quot;There are &quot;</span> + count + <span class="hljs-string">&quot; messages in exampleQueue&quot;</span>);
</code></pre>
<p>Management operation name and parameters must conform to the Java interfaces
defined in the <code>management</code> packages.</p>
<p>Names of the resources are built using the helper class
<code>org.apache.activemq.artemis.api.core.management.ResourceNames</code> and are
straightforward (e.g. <code>queue.exampleQueue</code> for <code>QueueControl</code> of the Queue
<code>exampleQueue</code>, or <code>broker</code> for the <code>ActiveMQServerControl</code>).</p>
<blockquote>
<p><strong>Note:</strong></p>
<p>The <code>ManagementHelper</code> class can be used only with Core JMS messages. When
called with a message from a different JMS library, an exception will be
thrown.</p>
</blockquote>
<h3 id="configuring-management">Configuring Management</h3>
<p>The management address to send management messages is configured in
<code>broker.xml</code>:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">management-address</span>&gt;</span>activemq.management<span class="hljs-tag">&lt;/<span class="hljs-name">management-address</span>&gt;</span>
</code></pre>
<p>By default, the address is <code>activemq.management</code>.</p>
<p>The management address requires a <em>special</em> user permission <code>manage</code> to be able
to receive and handle management messages. This is also configured in
broker.xml:</p>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- users with the admin role will be allowed to manage --&gt;</span>
<span class="hljs-comment">&lt;!-- Apache ActiveMQ Artemis using management messages --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">security-setting</span> <span class="hljs-attr">match</span>=<span class="hljs-string">&quot;activemq.management&quot;</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">permission</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;manage&quot;</span> <span class="hljs-attr">roles</span>=<span class="hljs-string">&quot;admin&quot;</span> /&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">security-setting</span>&gt;</span>
</code></pre>
<h3 id="example">Example</h3>
<p>See the <a href="examples.html#management">Management Example</a> which shows how to use JMS
messages to manage the Apache ActiveMQ Artemis server.</p>
<h2 id="management-notifications">Management Notifications</h2>
<p>Apache ActiveMQ Artemis emits <em>notifications</em> to inform listeners of
potentially interesting events (creation of new resources, security violation,
etc.).</p>
<p>These notifications can be received by two different ways:</p>
<ul>
<li><p>JMX notifications</p>
</li>
<li><p>Notification messages</p>
</li>
</ul>
<h3 id="jmx-notifications">JMX Notifications</h3>
<p>If JMX is enabled (see Configuring JMX section), JMX notifications can be
received by subscribing to
<code>org.apache.activemq.artemis:type=Broker,brokerName=&lt;broker
name&gt;,module=Core,serviceType=Server</code> for notifications on resources.</p>
<h3 id="notification-messages">Notification Messages</h3>
<p>Apache ActiveMQ Artemis defines a special <em>management notification address</em>.
Queues can be bound to this address so that clients will receive management
notifications as messages.</p>
<p>A client which wants to receive management notifications must create a queue
bound to the management notification address. It can then receive the
notifications from its queue.</p>
<p>Notifications messages are regular messages with additional properties
corresponding to the notification (its type, when it occurred, the resources
which were concerned, etc.).</p>
<p>Since notifications are regular messages, it is possible to use message
selectors to filter out notifications and receives only a subset of all the
notifications emitted by the server.</p>
<h4 id="configuring-the-management-notification-address">Configuring The Management Notification Address</h4>
<p>The management notification address to receive management notifications is
configured in <code>broker.xml</code>:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">management-notification-address</span>&gt;</span>activemq.notifications<span class="hljs-tag">&lt;/<span class="hljs-name">management-notification-address</span>&gt;</span>
</code></pre>
<p>By default, the address is <code>activemq.notifications</code>.</p>
<h4 id="receiving-notification-messages">Receiving Notification Messages</h4>
<p>Apache ActiveMQ Artemis&apos;s Core JMS Client can be used to receive notifications:</p>
<pre><code class="lang-java">Topic notificationsTopic = ActiveMQJMSClient.createTopic(<span class="hljs-string">&quot;activemq.notifications&quot;</span>);
Session session = ...
MessageConsumer notificationConsumer = session.createConsumer(notificationsTopic);
notificationConsumer.setMessageListener(<span class="hljs-keyword">new</span> MessageListener() {
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onMessage</span><span class="hljs-params">(Message notif)</span> </span>{
System.out.println(<span class="hljs-string">&quot;------------------------&quot;</span>);
System.out.println(<span class="hljs-string">&quot;Received notification:&quot;</span>);
<span class="hljs-keyword">try</span> {
Enumeration propertyNames = notif.getPropertyNames();
<span class="hljs-keyword">while</span> (propertyNames.hasMoreElements()) {
String propertyName = (String)propertyNames.nextElement();
System.out.format(<span class="hljs-string">&quot; %s: %s\n&quot;</span>, propertyName, notif.getObjectProperty(propertyName));
}
} <span class="hljs-keyword">catch</span> (JMSException e) {
}
System.out.println(<span class="hljs-string">&quot;------------------------&quot;</span>);
}
});
</code></pre>
<h3 id="example">Example</h3>
<p>See the <a href="examples.html#management-notification">Management Notification Example</a>
which shows how to use a JMS <code>MessageListener</code> to receive management
notifications from ActiveMQ Artemis server.</p>
<h3 id="notification-types-and-headers">Notification Types and Headers</h3>
<p>Below is a list of all the different kinds of notifications as well as which
headers are on the messages. Every notification has a <code>_AMQ_NotifType</code> (value
noted in parentheses) and <code>_AMQ_NotifTimestamp</code> header. The timestamp is the
un-formatted result of a call to <code>java.lang.System.currentTimeMillis()</code>.</p>
<ul>
<li><p><code>BINDING_ADDED</code> (0)</p>
<p><code>_AMQ_Binding_Type</code>, <code>_AMQ_Address</code>, <code>_AMQ_ClusterName</code>,
<code>_AMQ_RoutingName</code>, <code>_AMQ_Binding_ID</code>, <code>_AMQ_Distance</code>,
<code>_AMQ_FilterString</code></p>
</li>
<li><p><code>BINDING_REMOVED</code> (1)</p>
<p><code>_AMQ_Address</code>, <code>_AMQ_ClusterName</code>, <code>_AMQ_RoutingName</code>,
<code>_AMQ_Binding_ID</code>, <code>_AMQ_Distance</code>, <code>_AMQ_FilterString</code></p>
</li>
<li><p><code>CONSUMER_CREATED</code> (2)</p>
<p><code>_AMQ_Address</code>, <code>_AMQ_ClusterName</code>, <code>_AMQ_RoutingName</code>, <code>_AMQ_Distance</code>,
<code>_AMQ_ConsumerCount</code>, <code>_AMQ_User</code>, <code>_AMQ_ValidatedUser</code>, <code>_AMQ_RemoteAddress</code>,
<code>_AMQ_SessionName</code>, <code>_AMQ_FilterString</code>, <code>_AMQ_CertSubjectDN</code></p>
</li>
<li><p><code>CONSUMER_CLOSED</code> (3)</p>
<p><code>_AMQ_Address</code>, <code>_AMQ_ClusterName</code>, <code>_AMQ_RoutingName</code>, <code>_AMQ_Distance</code>,
<code>_AMQ_ConsumerCount</code>, <code>_AMQ_User</code>, <code>_AMQ_RemoteAddress</code>,
<code>_AMQ_SessionName</code>, <code>_AMQ_FilterString</code></p>
</li>
<li><p><code>SECURITY_AUTHENTICATION_VIOLATION</code> (6)</p>
<p><code>_AMQ_User</code>, <code>_AMQ_CertSubjectDN</code>, <code>_AMQ_RemoteAddress</code></p>
</li>
<li><p><code>SECURITY_PERMISSION_VIOLATION</code> (7)</p>
<p><code>_AMQ_Address</code>, <code>_AMQ_CheckType</code>, <code>_AMQ_User</code></p>
</li>
<li><p><code>DISCOVERY_GROUP_STARTED</code> (8)</p>
<p><code>name</code></p>
</li>
<li><p><code>DISCOVERY_GROUP_STOPPED</code> (9)</p>
<p><code>name</code></p>
</li>
<li><p><code>BROADCAST_GROUP_STARTED</code> (10)</p>
<p><code>name</code></p>
</li>
<li><p><code>BROADCAST_GROUP_STOPPED</code> (11)</p>
<p><code>name</code></p>
</li>
<li><p><code>BRIDGE_STARTED</code> (12)</p>
<p><code>name</code></p>
</li>
<li><p><code>BRIDGE_STOPPED</code> (13)</p>
<p><code>name</code></p>
</li>
<li><p><code>CLUSTER_CONNECTION_STARTED</code> (14)</p>
<p><code>name</code></p>
</li>
<li><p><code>CLUSTER_CONNECTION_STOPPED</code> (15)</p>
<p><code>name</code></p>
</li>
<li><p><code>ACCEPTOR_STARTED</code> (16)</p>
<p><code>factory</code>, <code>id</code></p>
</li>
<li><p><code>ACCEPTOR_STOPPED</code> (17)</p>
<p><code>factory</code>, <code>id</code></p>
</li>
<li><p><code>PROPOSAL</code> (18)</p>
<p><code>_JBM_ProposalGroupId</code>, <code>_JBM_ProposalValue</code>, <code>_AMQ_Binding_Type</code>,
<code>_AMQ_Address</code>, <code>_AMQ_Distance</code></p>
</li>
<li><p><code>PROPOSAL_RESPONSE</code> (19)</p>
<p><code>_JBM_ProposalGroupId</code>, <code>_JBM_ProposalValue</code>,
<code>_JBM_ProposalAltValue</code>, <code>_AMQ_Binding_Type</code>, <code>_AMQ_Address</code>,
<code>_AMQ_Distance</code></p>
</li>
<li><p><code>CONSUMER_SLOW</code> (21)</p>
<p><code>_AMQ_Address</code>, <code>_AMQ_ConsumerCount</code>, <code>_AMQ_RemoteAddress</code>,
<code>_AMQ_ConnectionName</code>, <code>_AMQ_ConsumerName</code>, <code>_AMQ_SessionName</code></p>
</li>
<li><p><code>ADDRESS_ADDED</code> (22)</p>
<p><code>_AMQ_Address</code>, <code>_AMQ_Routing_Type</code></p>
</li>
<li><p><code>ADDRESS_REMOVED</code> (23)</p>
<p><code>_AMQ_Address</code>, <code>_AMQ_Routing_Type</code></p>
</li>
<li><p><code>CONNECTION_CREATED</code> (24)</p>
<p><code>_AMQ_ConnectionName</code>, <code>_AMQ_RemoteAddress</code></p>
</li>
<li><p><code>CONNECTION_DESTROYED</code> (25)</p>
<p><code>_AMQ_ConnectionName</code>, <code>_AMQ_RemoteAddress</code></p>
</li>
<li><p><code>SESSION_CREATED</code> (26)</p>
<p><code>_AMQ_ConnectionName</code>, <code>_AMQ_User</code>, <code>_AMQ_SessionName</code></p>
</li>
<li><p><code>SESSION_CLOSED</code> (27)</p>
<p><code>_AMQ_ConnectionName</code>, <code>_AMQ_User</code>, <code>_AMQ_SessionName</code></p>
</li>
<li><p><code>MESSAGE_DELIVERED</code> (28)</p>
<p><code>_AMQ_Address</code>, <code>_AMQ_Routing_Type</code>, <code>_AMQ_RoutingName</code>,
<code>_AMQ_ConsumerName</code>, <code>_AMQ_Message_ID</code></p>
</li>
<li><p><code>MESSAGE_EXPIRED</code> (29)</p>
<p><code>_AMQ_Address</code>, <code>_AMQ_Routing_Type</code>, <code>_AMQ_RoutingName</code>,
<code>_AMQ_ConsumerName</code>, <code>_AMQ_Message_ID</code></p>
</li>
</ul>
<h2 id="message-counters">Message Counters</h2>
<p>Message counters can be used to obtain information on queues <em>over time</em> as
Apache ActiveMQ Artemis keeps a history on queue metrics.</p>
<p>They can be used to show <em>trends</em> on queues. For example, using the management
API, it would be possible to query the number of messages in a queue at regular
interval. However, this would not be enough to know if the queue is used: the
number of messages can remain constant because nobody is sending or receiving
messages from the queue or because there are as many messages sent to the queue
than messages consumed from it. The number of messages in the queue remains
the same in both cases but its use is widely different.</p>
<p>Message counters give additional information about the queues:</p>
<ul>
<li><p><code>count</code></p>
<p>The <em>total</em> number of messages added to the queue since the server was
started</p>
</li>
<li><p><code>countDelta</code></p>
<p>the number of messages added to the queue <em>since the last message counter
update</em></p>
</li>
<li><p><code>messageCount</code></p>
<p>The <em>current</em> number of messages in the queue</p>
</li>
<li><p><code>messageCountDelta</code></p>
<p>The <em>overall</em> number of messages added/removed from the queue <em>since the last
message counter update</em>. For example, if <code>messageCountDelta</code> is equal to <code>-10</code>
this means that overall 10 messages have been removed from the queue (e.g. 2
messages were added and 12 were removed)</p>
</li>
<li><p><code>lastAddTimestamp</code></p>
<p>The timestamp of the last time a message was added to the queue</p>
</li>
<li><p><code>udpateTimestamp</code></p>
<p>The timestamp of the last message counter update</p>
<p>These attributes can be used to determine other meaningful data as well. For
example, to know specifically how many messages were <em>consumed</em> from the queue
since the last update simply subtract the <code>messageCountDelta</code> from
<code>countDelta</code>.</p>
</li>
</ul>
<h3 id="configuring-message-counters">Configuring Message Counters</h3>
<p>By default, message counters are disabled as it might have a small negative
effect on memory.</p>
<p>To enable message counters, you can set it to <code>true</code> in <code>broker.xml</code>:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">message-counter-enabled</span>&gt;</span>true<span class="hljs-tag">&lt;/<span class="hljs-name">message-counter-enabled</span>&gt;</span>
</code></pre>
<p>Message counters keep a history of the queue metrics (10 days by default) and
sample all the queues at regular interval (10 seconds by default). If message
counters are enabled, these values should be configured to suit your messaging
use case in <code>broker.xml</code>:</p>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- keep history for a week --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">message-counter-max-day-history</span>&gt;</span>7<span class="hljs-tag">&lt;/<span class="hljs-name">message-counter-max-day-history</span>&gt;</span>
<span class="hljs-comment">&lt;!-- sample the queues every minute (60000ms) --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">message-counter-sample-period</span>&gt;</span>60000<span class="hljs-tag">&lt;/<span class="hljs-name">message-counter-sample-period</span>&gt;</span>
</code></pre>
<p>Message counters can be retrieved using the Management API. For example, to
retrieve message counters on a queue using JMX:</p>
<pre><code class="lang-java"><span class="hljs-comment">// retrieve a connection to Apache ActiveMQ Artemis&apos;s MBeanServer</span>
MBeanServerConnection mbsc = ...
QueueControlMBean queueControl = (QueueControl)MBeanServerInvocationHandler.newProxyInstance(mbsc,
on,
QueueControl.class,
<span class="hljs-keyword">false</span>);
<span class="hljs-comment">// message counters are retrieved as a JSON String</span>
String counters = queueControl.listMessageCounter();
<span class="hljs-comment">// use the MessageCounterInfo helper class to manipulate message counters more easily</span>
MessageCounterInfo messageCounter = MessageCounterInfo.fromJSON(counters);
System.out.format(<span class="hljs-string">&quot;%s message(s) in the queue (since last sample: %s)\n&quot;</span>,
messageCounter.getMessageCount(),
messageCounter.getMessageCountDelta());
</code></pre>
<h3 id="example">Example</h3>
<p>See the <a href="examples.html#message-counter">Message Counter Example</a> which shows how
to use message counters to retrieve information on a queue.</p>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="pre-acknowledge.html" class="navigation navigation-prev " aria-label="Previous page: Extra Acknowledge Modes">
<i class="fa fa-angle-left"></i>
</a>
<a href="management-console.html" class="navigation navigation-next " aria-label="Next page: Management Console">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Management","level":"1.46","depth":1,"next":{"title":"Management Console","level":"1.47","depth":1,"path":"management-console.md","ref":"management-console.md","articles":[]},"previous":{"title":"Extra Acknowledge Modes","level":"1.45","depth":1,"path":"pre-acknowledge.md","ref":"pre-acknowledge.md","articles":[]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"github":"apache/activemq-artemis","theme":"default","githubHost":"https://github.com/","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"ActiveMQ Artemis Documentation","links":{"home":"http://activemq.apache.org/artemis","issues":"https://issues.apache.org/jira/browse/ARTEMIS","contribute":"http://activemq.apache.org/contributing.html"},"gitbook":"3.x.x","description":"ActiveMQ Artemis User Guide and Reference Documentation"},"file":{"path":"management.md","mtime":"2020-04-27T19:30:24.000Z","type":"markdown"},"gitbook":{"version":"3.1.1","time":"2020-04-29T20:47:49.444Z"},"basePath":".","book":{"language":""}});
});
</script>
</div>
<script src="gitbook/gitbook.js"></script>
<script src="gitbook/theme.js"></script>
<script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="gitbook/gitbook-plugin-search/search.js"></script>
<script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>