2014-12-11 07:17:29 -05:00
|
|
|
# Management
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Apache ActiveMQ Artemis has an extensive *management API* 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.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
There are numerous ways to access Apache ActiveMQ Artemis management API:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Using JMX -- *JMX* is the standard way to manage Java applications
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
- Using Jolokia -- Jolokia exposes the JMX API of an application through an
|
|
|
|
*HTTP interface*
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Using the Core Client -- management operations are sent to Apache ActiveMQ
|
|
|
|
Artemis server using *Core Client messages*
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Using any JMS Client -- management operations are sent to Apache ActiveMQ
|
|
|
|
Artemis server using *JMS Client messages*
|
2017-07-31 06:26:28 -04:00
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
- Web Console -- a web application which provides a graphical interface to the
|
|
|
|
management API.
|
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
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.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Besides these four management interfaces, a [Web Console](management-console.md)
|
|
|
|
and a Command Line *management utility* are also available to administrators of
|
|
|
|
ActiveMQ Artemis.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The choice depends on your requirements, your application settings, and your
|
|
|
|
environment to decide which way suits you best.
|
2015-12-15 07:31:21 -05:00
|
|
|
|
2014-12-11 07:17:29 -05:00
|
|
|
## The Management API
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Regardless of the way you *invoke* management operations, the management API is
|
|
|
|
the same.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
For each *managed resource*, there exists a Java interface describing what
|
|
|
|
operations can be invoked for this type of resource.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
To learn about available *management operations*, see the Javadoc for these
|
|
|
|
interfaces. They are located in the
|
2017-07-31 06:26:28 -04:00
|
|
|
`org.apache.activemq.artemis.api.core.management` package and they are named
|
|
|
|
with the word `Control` at the end.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
### Server Management
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2017-07-31 06:26:28 -04:00
|
|
|
The `ActiveMQServerControl` interface is the entry point for broker management.
|
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Listing, creating, deploying and destroying queues
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
A list of deployed queues can be retrieved using the `getQueueNames()`
|
|
|
|
method.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Queues can be created or destroyed using the management operations
|
|
|
|
`createQueue()` or `deployQueue()` or `destroyQueue()`.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`createQueue` will fail if the queue already exists while `deployQueue` will
|
|
|
|
do nothing.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Listing and closing remote connections
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Client's remote addresses can be retrieved using `listRemoteAddresses()`. It
|
|
|
|
is also possible to close the connections associated with a remote address
|
|
|
|
using the `closeConnectionsForAddress()` method.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Alternatively, connection IDs can be listed using `listConnectionIDs()` and
|
|
|
|
all the sessions for a given connection ID can be listed using
|
|
|
|
`listSessions()`.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Transaction heuristic operations
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2020-11-13 06:07:15 -05:00
|
|
|
In case of a server crash, when the server restarts, it possible that some
|
2018-03-09 10:07:38 -05:00
|
|
|
transaction requires manual intervention. The `listPreparedTransactions()`
|
|
|
|
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 `commitPreparedTransaction()` or
|
|
|
|
`rollbackPreparedTransaction()` method can be used to resolve heuristic
|
|
|
|
transactions. Heuristically completed transactions can be listed using the
|
|
|
|
`listHeuristicCommittedTransactions()` and
|
|
|
|
`listHeuristicRolledBackTransactions` methods.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Enabling and resetting Message counters
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Message counters can be enabled or disabled using the
|
|
|
|
`enableMessageCounters()` or `disableMessageCounters()` method. To reset
|
|
|
|
message counters, it is possible to invoke `resetAllMessageCounters()` and
|
|
|
|
`resetAllMessageCounterHistories()` methods.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Retrieving the server configuration and attributes
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The `ActiveMQServerControl` exposes Apache ActiveMQ Artemis server
|
|
|
|
configuration through all its attributes (e.g. `getVersion()` method to
|
|
|
|
retrieve the server's version, etc.)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Listing, creating and destroying Core bridges and diverts
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
A list of deployed core bridges (resp. diverts) can be retrieved using the
|
|
|
|
`getBridgeNames()` (resp. `getDivertNames()`) method.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Core bridges (resp. diverts) can be created or destroyed using the management
|
|
|
|
operations `createBridge()` and `destroyBridge()` (resp. `createDivert()` and
|
|
|
|
`destroyDivert()`).
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2020-06-25 07:06:52 -04:00
|
|
|
Diverts can be updated using the management operation `updateDivert()`.
|
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- It is possible to stop the server and force failover to occur with any
|
|
|
|
currently attached clients.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
To do this use the `forceFailover()` operation.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
> **Note:**
|
|
|
|
>
|
|
|
|
> 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.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
### Address Management
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2017-07-31 06:26:28 -04:00
|
|
|
Individual addresses can be managed using the `AddressControl` interface.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Modifying roles and permissions for an address
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
You can add or remove roles associated to a queue using the `addRole()` or
|
|
|
|
`removeRole()` methods. You can list all the roles associated to the queue with
|
|
|
|
the `getRoles()` method
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2019-06-25 05:40:45 -04:00
|
|
|
- Pausing and resuming Address
|
|
|
|
|
|
|
|
The `AddressControl` 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.
|
2020-12-07 13:49:13 -05:00
|
|
|
Thus all messages sent to the address will be received but not delivered. When it is
|
2019-06-25 05:40:45 -04:00
|
|
|
resumed, delivering will occur again.
|
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
### Queue Management
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The bulk of the management API deals with queues. The `QueueControl` interface
|
|
|
|
defines the queue management operations.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
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.)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
> **Note:**
|
2017-07-31 06:26:28 -04:00
|
|
|
>
|
2018-03-09 10:07:38 -05:00
|
|
|
> Passing `null` or an empty string in the `filter` parameter means that the
|
|
|
|
> management operation will be performed on *all messages* in a queue.
|
2017-07-31 06:26:28 -04:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Expiring, sending to a dead letter address and moving messages
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Messages can be expired from a queue by using the `expireMessages()` method.
|
|
|
|
If an expiry address is defined, messages will be sent to it, otherwise they
|
2018-08-01 11:37:06 -04:00
|
|
|
are discarded.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Messages can also be sent to a dead letter address with the
|
|
|
|
`sendMessagesToDeadLetterAddress()` method. It returns the number of messages
|
|
|
|
which are sent to the dead letter address. If a dead letter address is not
|
2018-08-01 11:37:06 -04:00
|
|
|
defined, message are removed from the queue and discarded.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Messages can also be moved from a queue to another queue by using the
|
|
|
|
`moveMessages()` method.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Listing and removing messages
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Messages can be listed from a queue by using the `listMessages()` method
|
|
|
|
which returns an array of `Map`, one `Map` for each message.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Messages can also be removed from the queue by using the `removeMessages()`
|
|
|
|
method which returns a `boolean` for the single message ID variant or the
|
|
|
|
number of removed messages for the filter variant. The `removeMessages()`
|
|
|
|
method takes a `filter` argument to remove only filtered messages. Setting the
|
|
|
|
filter to an empty string will in effect remove all messages.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Counting messages
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The number of messages in a queue is returned by the `getMessageCount()`
|
|
|
|
method. Alternatively, the `countMessages()` will return the number of messages
|
|
|
|
in the queue which *match a given filter*.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Changing message priority
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The message priority can be changed by using the `changeMessagesPriority()`
|
|
|
|
method which returns a `boolean` for the single message ID variant or the
|
|
|
|
number of updated messages for the filter variant.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Message counters
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Message counters can be listed for a queue with the `listMessageCounter()`
|
|
|
|
and `listMessageCounterHistory()` methods (see Message Counters section). The
|
|
|
|
message counters can also be reset for a single queue using the
|
|
|
|
`resetMessageCounter()` method.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Retrieving the queue attributes
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The `QueueControl` exposes queue settings through its attributes (e.g.
|
|
|
|
`getFilter()` to retrieve the queue's filter if it was created with one,
|
|
|
|
`isDurable()` to know whether the queue is durable or not, etc.)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Pausing and resuming Queues
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The `QueueControl` can pause and resume the underlying queue. When a queue is
|
|
|
|
paused, it will receive messages but will not deliver them. When it's resumed,
|
|
|
|
it'll begin delivering the queued messages, if any.
|
2020-06-01 07:53:00 -04:00
|
|
|
|
|
|
|
- Disabling and Enabling Queues
|
|
|
|
|
|
|
|
The `QueueControl` can disable and enable the underlying queue. When a queue is
|
|
|
|
disabled, it will not longer have messages routed to it. When it's enabled,
|
|
|
|
it'll begin having messages routed to it again.
|
|
|
|
|
|
|
|
This is useful where you may need to disable message routing to a queue but wish to keep consumers active
|
|
|
|
to investigate issues, without causing further message build up in the queue.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
### Other Resources Management
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
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:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Acceptors
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
They can be started or stopped using the `start()` or. `stop()` method on the
|
|
|
|
`AcceptorControl` interface. The acceptors parameters can be retrieved using
|
|
|
|
the `AcceptorControl` attributes (see [Understanding
|
|
|
|
Acceptors](configuring-transports.md))
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Diverts
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
They can be started or stopped using the `start()` or `stop()` method on the
|
|
|
|
`DivertControl` interface. Diverts parameters can be retrieved using the
|
|
|
|
`DivertControl` attributes (see [Diverting and Splitting Message
|
|
|
|
Flows)](diverts.md))
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Bridges
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
They can be started or stopped using the `start()` (resp. `stop()`) method on
|
|
|
|
the `BridgeControl` interface. Bridges parameters can be retrieved using the
|
|
|
|
`BridgeControl` attributes (see [Core bridges](core-bridges.md))
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Broadcast groups
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
They can be started or stopped using the `start()` or `stop()` method on the
|
|
|
|
`BroadcastGroupControl` interface. Broadcast groups parameters can be retrieved
|
|
|
|
using the `BroadcastGroupControl` attributes (see [Clusters](clusters.md))
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Cluster connections
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
They can be started or stopped using the `start()` or `stop()` method on the
|
|
|
|
`ClusterConnectionControl` interface. Cluster connections parameters can be
|
|
|
|
retrieved using the `ClusterConnectionControl` attributes (see
|
|
|
|
[Clusters](clusters.md))
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
## Management Via JMX
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2015-04-27 17:32:30 -04:00
|
|
|
Apache ActiveMQ Artemis can be managed using
|
2014-12-04 10:25:29 -05:00
|
|
|
[JMX](http://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html).
|
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
The management API is exposed by Apache ActiveMQ Artemis using MBeans. By
|
|
|
|
default, Apache ActiveMQ Artemis registers its resources with the domain
|
|
|
|
`org.apache.activemq.artemis`. For example, the `ObjectName` to manage the
|
|
|
|
anycast queue `exampleQueue` on the address `exampleAddress` is:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
```
|
|
|
|
org.apache.activemq.artemis:broker=<brokerName>,component=addresses,address="exampleAddress",subcomponent=queues,routing-type="anycast",queue="exampleQueue"
|
|
|
|
```
|
2014-12-04 10:25:29 -05:00
|
|
|
|
|
|
|
and the MBean is:
|
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
```
|
|
|
|
org.apache.activemq.artemis.api.core.management.QueueControl
|
|
|
|
```
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
The MBean's `ObjectName` is built using the helper class
|
|
|
|
`org.apache.activemq.artemis.api.core.management.ObjectNameBuilder`. Example
|
|
|
|
usage of the `ObjectNameBuilder` to obtain `ActiveMQServerControl`'s name:
|
2017-07-31 06:26:28 -04:00
|
|
|
|
|
|
|
``` java
|
|
|
|
brokerName = "0.0.0.0"; // configured e.g. in broker.xml <broker-name> element
|
|
|
|
objectNameBuilder = ObjectNameBuilder.create(ArtemisResolver.DEFAULT_DOMAIN, brokerName, true);
|
|
|
|
serverObjectName = objectNameBuilder.getActiveMQServerObjectName()
|
|
|
|
```
|
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
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
|
2014-12-04 10:25:29 -05:00
|
|
|
proxies of the MBeans.
|
|
|
|
|
2014-12-11 07:17:29 -05:00
|
|
|
### Configuring JMX
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
By default, JMX is enabled to manage Apache ActiveMQ Artemis. It can be
|
|
|
|
disabled by setting `jmx-management-enabled` to `false` in `broker.xml`:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
```xml
|
|
|
|
<jmx-management-enabled>false</jmx-management-enabled>
|
|
|
|
```
|
|
|
|
|
2018-03-07 14:07:04 -05:00
|
|
|
#### Role Based Authorisation for JMX
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Although by default Artemis uses the Java Virtual Machine's `Platform
|
2021-04-01 13:17:27 -04:00
|
|
|
MBeanServer` this is guarded using role based authorisation that leverages
|
|
|
|
the broker's JAAS plugin support. This is configured via the `authorisation`
|
2018-03-09 10:07:38 -05:00
|
|
|
element in the `management.xml` configuration file and can be used to restrict
|
2021-04-01 13:17:27 -04:00
|
|
|
access to attributes and methods on MBeans.
|
2017-10-12 08:53:19 -04:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
There are 3 elements within the `authorisation` element, `whitelist`,
|
2021-04-01 13:17:27 -04:00
|
|
|
`default-access` and `role-access`. Lets discuss each in turn.
|
2017-10-12 08:53:19 -04:00
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
Whitelist contains a list of MBeans that will bypass the authorisation, this
|
|
|
|
is typically used for any MBeans that are needed by the console to run etc. The
|
2018-03-09 10:07:38 -05:00
|
|
|
default configuration is:
|
2017-10-12 08:53:19 -04:00
|
|
|
|
|
|
|
```xml
|
|
|
|
<whitelist>
|
|
|
|
<entry domain="hawtio"/>
|
|
|
|
</whitelist>
|
|
|
|
```
|
2021-04-01 13:17:27 -04:00
|
|
|
This means that any MBean with the domain `hawtio` will be allowed access
|
2018-03-09 10:07:38 -05:00
|
|
|
without authorisation. for instance `hawtio:plugin=artemis`. You can also use
|
2021-04-01 13:17:27 -04:00
|
|
|
wildcards for the MBean properties so the following would also match.
|
2017-10-12 08:53:19 -04:00
|
|
|
|
|
|
|
```xml
|
|
|
|
<whitelist>
|
|
|
|
<entry domain="hawtio" key="type=*"/>
|
|
|
|
</whitelist>
|
|
|
|
```
|
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
The `role-access`defines how roles are mapped to particular MBeans and its
|
2018-03-09 10:07:38 -05:00
|
|
|
attributes and methods, the default configuration looks like:
|
2017-10-12 08:53:19 -04:00
|
|
|
|
|
|
|
```xml
|
|
|
|
<role-access>
|
2018-03-09 10:07:38 -05:00
|
|
|
<match domain="org.apache.activemq.artemis">
|
|
|
|
<access method="list*" roles="view,update,amq"/>
|
|
|
|
<access method="get*" roles="view,update,amq"/>
|
|
|
|
<access method="is*" roles="view,update,amq"/>
|
|
|
|
<access method="set*" roles="update,amq"/>
|
|
|
|
<access method="*" roles="amq"/>
|
|
|
|
</match>
|
2017-10-12 08:53:19 -04:00
|
|
|
</role-access>
|
|
|
|
```
|
2021-04-01 13:17:27 -04:00
|
|
|
This contains 1 match and will be applied to any MBean that has the domain
|
|
|
|
`org.apache.activemq.artemis`. Any access to any MBeans that have this domain
|
2018-03-09 10:07:38 -05:00
|
|
|
are controlled by the `access` 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
|
2021-04-01 13:17:27 -04:00
|
|
|
try the invoke a method called `listMessages` on an MBean with the
|
2018-03-09 10:07:38 -05:00
|
|
|
`org.apache.activemq.artemis` domain then this would match the `access` with
|
|
|
|
the method of `list*`. You could also explicitly configure this by using the
|
|
|
|
full method name, like so:
|
2017-10-12 08:53:19 -04:00
|
|
|
|
|
|
|
```xml
|
|
|
|
<access method="listMessages" roles="view,update,amq"/>
|
|
|
|
```
|
2021-04-01 13:17:27 -04:00
|
|
|
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:
|
2017-10-12 08:53:19 -04:00
|
|
|
|
|
|
|
```xml
|
2017-12-15 14:52:20 -05:00
|
|
|
<match domain="org.apache.activemq.artemis" key="subcomponent=queues">
|
2017-10-12 08:53:19 -04:00
|
|
|
<access method="list*" roles="view,update,amq"/>
|
|
|
|
<access method="get*" roles="view,update,amq"/>
|
|
|
|
<access method="is*" roles="view,update,amq"/>
|
|
|
|
<access method="set*" roles="update,amq"/>
|
|
|
|
<access method="*" roles="amq"/>
|
|
|
|
</match>
|
|
|
|
```
|
2018-03-09 10:07:38 -05:00
|
|
|
You could also match a specific queue for instance:
|
2017-10-12 08:53:19 -04:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
```
|
|
|
|
org.apache.activemq.artemis:broker=<brokerName>,component=addresses,address="exampleAddress",subcomponent=queues,routing-type="anycast",queue="exampleQueue"
|
|
|
|
```
|
2017-10-12 08:53:19 -04:00
|
|
|
|
|
|
|
by configuring:
|
|
|
|
|
|
|
|
```xml
|
2017-12-15 14:52:20 -05:00
|
|
|
<match domain="org.apache.activemq.artemis" key="queue=exampleQueue">
|
2017-10-12 08:53:19 -04:00
|
|
|
<access method="list*" roles="view,update,amq"/>
|
|
|
|
<access method="get*" roles="view,update,amq"/>
|
|
|
|
<access method="is*" roles="view,update,amq"/>
|
|
|
|
<access method="set*" roles="update,amq"/>
|
2019-10-17 04:20:58 -04:00
|
|
|
<access method="*" roles="amq"/>
|
|
|
|
</match>
|
|
|
|
```
|
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
You can also use wildcards for the MBean properties so the following would
|
|
|
|
also match, allowing prefix match for the MBean properties.
|
2019-10-17 04:20:58 -04:00
|
|
|
|
|
|
|
```xml
|
|
|
|
<match domain="org.apache.activemq.artemis" key="queue=example*">
|
|
|
|
<access method="list*" roles="view,update,amq"/>
|
|
|
|
<access method="get*" roles="view,update,amq"/>
|
|
|
|
<access method="is*" roles="view,update,amq"/>
|
|
|
|
<access method="set*" roles="update,amq"/>
|
2017-10-12 08:53:19 -04:00
|
|
|
<access method="*" roles="amq"/>
|
|
|
|
</match>
|
|
|
|
```
|
|
|
|
|
2020-01-24 06:58:43 -05:00
|
|
|
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.
|
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
Access to JMX MBean attributes are converted to method calls so these are
|
2018-03-09 10:07:38 -05:00
|
|
|
controlled via the `set*`, `get*` and `is*`. The `*` access is the catch all
|
|
|
|
for everything other method that isn't specifically matched.
|
2017-10-12 08:53:19 -04:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The `default-access` element is basically the catch all for every method call
|
2018-10-08 16:05:46 -04:00
|
|
|
that isn't handled via the `role-access` configuration. This has the same
|
2018-03-09 10:07:38 -05:00
|
|
|
semantics as a `match` element.
|
2017-10-12 08:53:19 -04:00
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
#### Local JMX Access with JConsole
|
|
|
|
|
|
|
|
Due to the authorisation which is enabled by default Apache ActiveMQ Artemis
|
|
|
|
can *not* be managed locally using JConsole when connecting as a *local
|
|
|
|
process*. This is because JConsole does not pass any authentication information
|
|
|
|
when connecting this way which means the user cannot therefore be authorised
|
|
|
|
for any management operations. In order to use JConsole the user will either
|
|
|
|
have to disable authorisation by completely removing the `authorisation` element
|
|
|
|
from `management.xml` or by enabling remote access and providing the proper
|
|
|
|
username and password credentials (discussed next).
|
2017-10-12 08:53:19 -04:00
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
#### Remote JMX Access
|
2017-10-12 08:53:19 -04:00
|
|
|
|
|
|
|
By default remote JMX access to Artemis is disabled for security reasons.
|
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
Artemis has a JMX agent which allows access to JMX MBeans remotely. This is
|
2018-03-09 10:07:38 -05:00
|
|
|
configured via the `connector` element in the `management.xml` configuration
|
|
|
|
file. To enable this you simply add the following xml:
|
2017-10-12 08:53:19 -04:00
|
|
|
|
|
|
|
```xml
|
|
|
|
<connector connector-port="1099"/>
|
|
|
|
```
|
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
This exposes the agent remotely on the port 1099. If you were connecting via
|
2021-04-01 13:17:27 -04:00
|
|
|
JConsole you would connect as a remote process using the service url
|
2018-03-09 10:07:38 -05:00
|
|
|
`service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi` and an appropriate user
|
|
|
|
name and password.
|
2017-10-12 08:53:19 -04:00
|
|
|
|
|
|
|
You can also configure the connector using the following:
|
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `connector-host`
|
2017-10-18 04:58:39 -04:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The host to expose the agent on.
|
|
|
|
|
|
|
|
- `connector-port`
|
2017-10-18 04:58:39 -04:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The port to expose the agent on.
|
2018-11-07 08:49:23 -05:00
|
|
|
|
|
|
|
- `rmi-registry-port`
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `jmx-realm`
|
2017-10-18 04:58:39 -04:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The jmx realm to use for authentication, defaults to `activemq` to match the
|
|
|
|
JAAS configuration.
|
|
|
|
|
|
|
|
- `object-name`
|
2017-10-18 04:58:39 -04:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The object name to expose the remote connector on; default is
|
|
|
|
`connector:name=rmi`.
|
|
|
|
|
|
|
|
- `secured`
|
2017-10-18 04:58:39 -04:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Whether the connector is secured using SSL.
|
|
|
|
|
|
|
|
- `key-store-path`
|
2017-10-18 04:58:39 -04:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The location of the keystore.
|
2017-10-18 04:58:39 -04:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `key-store-password`
|
2017-10-18 04:58:39 -04:00
|
|
|
|
2018-09-13 17:50:07 -04:00
|
|
|
The keystore password. This can be [masked](masking-passwords.md).
|
2017-10-18 04:58:39 -04:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `key-store-provider`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The provider; `JKS` by default.
|
|
|
|
|
|
|
|
- `trust-store-path`
|
|
|
|
|
|
|
|
The location of the truststore.
|
|
|
|
|
|
|
|
- `trust-store-password`
|
|
|
|
|
2018-09-13 17:50:07 -04:00
|
|
|
The trustore password. This can be [masked](masking-passwords.md).
|
2018-03-09 10:07:38 -05:00
|
|
|
|
|
|
|
- `trust-store-provider`
|
|
|
|
|
|
|
|
The provider; `JKS` by default.
|
|
|
|
|
2018-09-13 17:50:07 -04:00
|
|
|
- `password-codec`
|
|
|
|
|
|
|
|
The fully qualified class name of the password codec to use. See the
|
|
|
|
[password masking](masking-passwords.md) documentation for more details on
|
|
|
|
how this works.
|
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
> **Note:**
|
2014-12-04 10:25:29 -05:00
|
|
|
>
|
2018-03-09 10:07:38 -05:00
|
|
|
> 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
|
2017-10-12 08:53:19 -04:00
|
|
|
> `-Djava.rmi.server.hostname=localhost`
|
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
> **Note:**
|
2017-10-12 08:53:19 -04:00
|
|
|
>
|
2018-03-09 10:07:38 -05:00
|
|
|
> Remote connections using the default JVM Agent not enabled by default as
|
2021-04-01 13:17:27 -04:00
|
|
|
> Artemis exposes the MBean Server via its own configuration. This is so
|
2018-03-09 10:07:38 -05:00
|
|
|
> 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 `management.xml` configuration.
|
|
|
|
> Please refer to [Java Management
|
|
|
|
> guide](https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html)
|
|
|
|
> to configure the server for remote management (system properties must be set
|
|
|
|
> in `artemis.profile`).
|
|
|
|
|
|
|
|
By default, Apache ActiveMQ Artemis server uses the JMX domain
|
|
|
|
"org.apache.activemq.artemis". To manage several Apache ActiveMQ Artemis
|
|
|
|
servers from the *same* MBeanServer, the JMX domain can be configured for each
|
|
|
|
individual Apache ActiveMQ Artemis server by setting `jmx-domain` in
|
|
|
|
`broker.xml`:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
```xml
|
|
|
|
<!-- use a specific JMX domain for ActiveMQ Artemis MBeans -->
|
|
|
|
<jmx-domain>my.org.apache.activemq</jmx-domain>
|
|
|
|
```
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2014-12-11 07:17:29 -05:00
|
|
|
### Example
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
See the [JMX Management Example](examples.md#jmx-management) which shows how to
|
|
|
|
use a remote connection to JMX and MBean proxies to manage Apache ActiveMQ
|
|
|
|
Artemis.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2015-01-23 09:28:07 -05:00
|
|
|
### Exposing JMX using Jolokia
|
|
|
|
|
2017-12-22 16:25:21 -05:00
|
|
|
The default Broker configuration ships with the [Jolokia](https://jolokia.org)
|
2018-03-09 10:07:38 -05:00
|
|
|
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
|
|
|
|
[Jolokia Documentation](https://jolokia.org/documentation.html), however a
|
|
|
|
simple example to query the broker's version would be to use a browser and go
|
|
|
|
to the URL
|
|
|
|
[http://username:password@localhost:8161/console/jolokia/read/org.apache.activemq.artemis:broker="0.0.0.0"/Version]().
|
2015-01-23 09:28:07 -05:00
|
|
|
|
|
|
|
This would give you back something like the following:
|
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
```
|
|
|
|
{"request":{"mbean":"org.apache.activemq.artemis:broker=\"0.0.0.0\"","attribute":"Version","type":"read"},"value":"2.0.0-SNAPSHOT","timestamp":1487017918,"status":200}
|
|
|
|
```
|
2015-01-23 09:28:07 -05:00
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
### JMX and the Web Console
|
2017-10-12 08:53:19 -04:00
|
|
|
|
2021-04-01 13:17:27 -04:00
|
|
|
The web console that ships with Artemis uses Jolokia under the covers which in
|
|
|
|
turn uses JMX. This will use the authentication configuration in the
|
2018-03-09 10:07:38 -05:00
|
|
|
`management.xml` file as described in the previous section. This means that
|
2021-04-01 13:17:27 -04:00
|
|
|
when MBeans are accessed via the console the credentials used to log into the
|
2018-03-09 10:07:38 -05:00
|
|
|
console and the roles associated with them. By default access to the console is
|
2021-04-01 13:17:27 -04:00
|
|
|
only allow via users with the `amq` role. This is configured in the
|
2018-03-09 10:07:38 -05:00
|
|
|
`artemis.profile` via the system property `-Dhawtio.role=amq`. You can
|
|
|
|
configure multiple roles by changing this to `-Dhawtio.roles=amq,view,update`.
|
2017-10-12 08:53:19 -04:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
If a user doesn't have the correct role to invoke a specific operation then
|
|
|
|
this will display an authorisation exception in the console.
|
2017-10-12 08:53:19 -04:00
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
## Using Management Message API
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The management message API in ActiveMQ Artemis is accessed by sending Core
|
|
|
|
Client messages to a special address, the *management address*.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2017-03-09 11:59:09 -05:00
|
|
|
*Management messages* are regular Core Client messages with well-known
|
2018-03-09 10:07:38 -05:00
|
|
|
properties that the server needs to understand to interact with the management
|
|
|
|
API:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- The name of the managed resource
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- The name of the management operation
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- The parameters of the management operation
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
When such a management message is sent to the management address, Apache
|
|
|
|
ActiveMQ Artemis server will handle it, extract the information, invoke the
|
2014-12-04 10:25:29 -05:00
|
|
|
operation on the managed resources and send a *management reply* to the
|
|
|
|
management message's reply-to address (specified by
|
|
|
|
`ClientMessageImpl.REPLYTO_HEADER_NAME`).
|
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
A `ClientConsumer` can be used to consume the management reply and retrieve the
|
|
|
|
result of the operation (if any) stored in the reply's body. For portability,
|
|
|
|
results are returned as a [JSON](https://json.org) String rather than Java
|
|
|
|
Serialization (the
|
2015-04-29 13:20:31 -04:00
|
|
|
`org.apache.activemq.artemis.api.core.management.ManagementHelper` can be used
|
2014-12-04 10:25:29 -05:00
|
|
|
to convert the JSON string to Java objects).
|
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
These steps can be simplified to make it easier to invoke management operations
|
|
|
|
using Core messages:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
1. Create a `ClientRequestor` to send messages to the management address and
|
|
|
|
receive replies
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
2. Create a `ClientMessage`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
3. Use the helper class
|
|
|
|
`org.apache.activemq.artemis.api.core.management.ManagementHelper` to fill
|
|
|
|
the message with the management properties
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
4. Send the message using the `ClientRequestor`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
5. Use the helper class
|
|
|
|
`org.apache.activemq.artemis.api.core.management.ManagementHelper` to
|
|
|
|
retrieve the operation result from the management reply.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
For example, to find out the number of messages in the queue `exampleQueue`:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
```java
|
2014-12-11 07:17:29 -05:00
|
|
|
ClientSession session = ...
|
2017-02-13 16:20:12 -05:00
|
|
|
ClientRequestor requestor = new ClientRequestor(session, "activemq.management");
|
2014-12-11 07:17:29 -05:00
|
|
|
ClientMessage message = session.createMessage(false);
|
2017-02-13 16:20:12 -05:00
|
|
|
ManagementHelper.putAttribute(message, "queue.exampleQueue", "messageCount");
|
2014-12-11 07:17:29 -05:00
|
|
|
session.start();
|
|
|
|
ClientMessage reply = requestor.request(m);
|
|
|
|
int count = (Integer) ManagementHelper.getResult(reply);
|
|
|
|
System.out.println("There are " + count + " messages in exampleQueue");
|
|
|
|
```
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Management operation name and parameters must conform to the Java interfaces
|
|
|
|
defined in the `management` packages.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
|
|
|
Names of the resources are built using the helper class
|
2015-04-29 13:20:31 -04:00
|
|
|
`org.apache.activemq.artemis.api.core.management.ResourceNames` and are
|
2017-07-31 06:26:28 -04:00
|
|
|
straightforward (e.g. `queue.exampleQueue` for `QueueControl` of the Queue
|
|
|
|
`exampleQueue`, or `broker` for the `ActiveMQServerControl`).
|
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
> **Note:**
|
2017-07-31 06:26:28 -04:00
|
|
|
>
|
2018-03-09 10:07:38 -05:00
|
|
|
> The `ManagementHelper` class can be used only with Core JMS messages. When
|
|
|
|
> called with a message from a different JMS library, an exception will be
|
|
|
|
> thrown.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2017-03-09 11:59:09 -05:00
|
|
|
### Configuring Management
|
2014-12-04 10:25:29 -05:00
|
|
|
|
|
|
|
The management address to send management messages is configured in
|
2015-04-29 05:30:31 -04:00
|
|
|
`broker.xml`:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
```xml
|
|
|
|
<management-address>activemq.management</management-address>
|
|
|
|
```
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2017-02-13 16:20:12 -05:00
|
|
|
By default, the address is `activemq.management`.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The management address requires a *special* user permission `manage` to be able
|
|
|
|
to receive and handle management messages. This is also configured in
|
|
|
|
broker.xml:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
```xml
|
|
|
|
<!-- users with the admin role will be allowed to manage -->
|
2018-03-09 10:07:38 -05:00
|
|
|
<!-- Apache ActiveMQ Artemis using management messages -->
|
2018-03-08 15:46:38 -05:00
|
|
|
<security-setting match="activemq.management">
|
|
|
|
<permission type="manage" roles="admin" />
|
|
|
|
</security-setting>
|
|
|
|
```
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2014-12-11 07:17:29 -05:00
|
|
|
### Example
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
See the [Management Example](examples.md#management) which shows how to use JMS
|
|
|
|
messages to manage the Apache ActiveMQ Artemis server.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2014-12-11 07:17:29 -05:00
|
|
|
## Management Notifications
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Apache ActiveMQ Artemis emits *notifications* to inform listeners of
|
|
|
|
potentially interesting events (creation of new resources, security violation,
|
2014-12-04 10:25:29 -05:00
|
|
|
etc.).
|
|
|
|
|
2017-07-31 06:26:28 -04:00
|
|
|
These notifications can be received by two different ways:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- JMX notifications
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- Notification messages
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2014-12-11 07:17:29 -05:00
|
|
|
### JMX Notifications
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
If JMX is enabled (see Configuring JMX section), JMX notifications can be
|
|
|
|
received by subscribing to
|
|
|
|
`org.apache.activemq.artemis:type=Broker,brokerName=<broker
|
|
|
|
name>,module=Core,serviceType=Server` for notifications on resources.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2017-07-31 06:26:28 -04:00
|
|
|
### Notification Messages
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Apache ActiveMQ Artemis defines a special *management notification address*.
|
|
|
|
Queues can be bound to this address so that clients will receive management
|
|
|
|
notifications as messages.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
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.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Notifications messages are regular messages with additional properties
|
|
|
|
corresponding to the notification (its type, when it occurred, the resources
|
|
|
|
which were concerned, etc.).
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
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.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2017-07-31 06:26:28 -04:00
|
|
|
#### Configuring The Management Notification Address
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The management notification address to receive management notifications is
|
|
|
|
configured in `broker.xml`:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
```xml
|
|
|
|
<management-notification-address>activemq.notifications</management-notification-address>
|
|
|
|
```
|
2014-12-04 10:25:29 -05:00
|
|
|
|
|
|
|
By default, the address is `activemq.notifications`.
|
|
|
|
|
2017-07-31 06:26:28 -04:00
|
|
|
#### Receiving Notification Messages
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2017-07-31 06:26:28 -04:00
|
|
|
Apache ActiveMQ Artemis's Core JMS Client can be used to receive notifications:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
```java
|
2017-07-31 06:26:28 -04:00
|
|
|
Topic notificationsTopic = ActiveMQJMSClient.createTopic("activemq.notifications");
|
2014-12-11 07:17:29 -05:00
|
|
|
|
|
|
|
Session session = ...
|
|
|
|
MessageConsumer notificationConsumer = session.createConsumer(notificationsTopic);
|
2018-03-09 10:07:38 -05:00
|
|
|
notificationConsumer.setMessageListener(new MessageListener() {
|
|
|
|
public void onMessage(Message notif) {
|
|
|
|
System.out.println("------------------------");
|
|
|
|
System.out.println("Received notification:");
|
|
|
|
try {
|
|
|
|
Enumeration propertyNames = notif.getPropertyNames();
|
|
|
|
while (propertyNames.hasMoreElements()) {
|
|
|
|
String propertyName = (String)propertyNames.nextElement();
|
|
|
|
System.out.format(" %s: %s\n", propertyName, notif.getObjectProperty(propertyName));
|
|
|
|
}
|
|
|
|
} catch (JMSException e) {
|
|
|
|
}
|
|
|
|
System.out.println("------------------------");
|
2014-12-11 07:17:29 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
```
|
|
|
|
### Example
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
See the [Management Notification Example](examples.md#management-notification)
|
|
|
|
which shows how to use a JMS `MessageListener` to receive management
|
|
|
|
notifications from ActiveMQ Artemis server.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2014-12-11 07:17:29 -05:00
|
|
|
### Notification Types and Headers
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Below is a list of all the different kinds of notifications as well as which
|
|
|
|
headers are on the messages. Every notification has a `_AMQ_NotifType` (value
|
|
|
|
noted in parentheses) and `_AMQ_NotifTimestamp` header. The timestamp is the
|
|
|
|
un-formatted result of a call to `java.lang.System.currentTimeMillis()`.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `BINDING_ADDED` (0)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`_AMQ_Binding_Type`, `_AMQ_Address`, `_AMQ_ClusterName`,
|
|
|
|
`_AMQ_RoutingName`, `_AMQ_Binding_ID`, `_AMQ_Distance`,
|
|
|
|
`_AMQ_FilterString`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `BINDING_REMOVED` (1)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`_AMQ_Address`, `_AMQ_ClusterName`, `_AMQ_RoutingName`,
|
|
|
|
`_AMQ_Binding_ID`, `_AMQ_Distance`, `_AMQ_FilterString`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `CONSUMER_CREATED` (2)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`_AMQ_Address`, `_AMQ_ClusterName`, `_AMQ_RoutingName`, `_AMQ_Distance`,
|
2018-10-16 09:01:45 -04:00
|
|
|
`_AMQ_ConsumerCount`, `_AMQ_User`, `_AMQ_ValidatedUser`, `_AMQ_RemoteAddress`,
|
|
|
|
`_AMQ_SessionName`, `_AMQ_FilterString`, `_AMQ_CertSubjectDN`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `CONSUMER_CLOSED` (3)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`_AMQ_Address`, `_AMQ_ClusterName`, `_AMQ_RoutingName`, `_AMQ_Distance`,
|
|
|
|
`_AMQ_ConsumerCount`, `_AMQ_User`, `_AMQ_RemoteAddress`,
|
|
|
|
`_AMQ_SessionName`, `_AMQ_FilterString`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `SECURITY_AUTHENTICATION_VIOLATION` (6)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-10-03 14:03:18 -04:00
|
|
|
`_AMQ_User`, `_AMQ_CertSubjectDN`, `_AMQ_RemoteAddress`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `SECURITY_PERMISSION_VIOLATION` (7)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`_AMQ_Address`, `_AMQ_CheckType`, `_AMQ_User`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `DISCOVERY_GROUP_STARTED` (8)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`name`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `DISCOVERY_GROUP_STOPPED` (9)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`name`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `BROADCAST_GROUP_STARTED` (10)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`name`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `BROADCAST_GROUP_STOPPED` (11)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`name`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `BRIDGE_STARTED` (12)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`name`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `BRIDGE_STOPPED` (13)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`name`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `CLUSTER_CONNECTION_STARTED` (14)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`name`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `CLUSTER_CONNECTION_STOPPED` (15)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`name`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `ACCEPTOR_STARTED` (16)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`factory`, `id`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `ACCEPTOR_STOPPED` (17)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`factory`, `id`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `PROPOSAL` (18)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`_JBM_ProposalGroupId`, `_JBM_ProposalValue`, `_AMQ_Binding_Type`,
|
|
|
|
`_AMQ_Address`, `_AMQ_Distance`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `PROPOSAL_RESPONSE` (19)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`_JBM_ProposalGroupId`, `_JBM_ProposalValue`,
|
|
|
|
`_JBM_ProposalAltValue`, `_AMQ_Binding_Type`, `_AMQ_Address`,
|
|
|
|
`_AMQ_Distance`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `CONSUMER_SLOW` (21)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
`_AMQ_Address`, `_AMQ_ConsumerCount`, `_AMQ_RemoteAddress`,
|
|
|
|
`_AMQ_ConnectionName`, `_AMQ_ConsumerName`, `_AMQ_SessionName`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-06-27 16:04:23 -04:00
|
|
|
- `ADDRESS_ADDED` (22)
|
|
|
|
|
|
|
|
`_AMQ_Address`, `_AMQ_Routing_Type`
|
|
|
|
|
|
|
|
- `ADDRESS_REMOVED` (23)
|
|
|
|
|
|
|
|
`_AMQ_Address`, `_AMQ_Routing_Type`
|
|
|
|
|
|
|
|
- `CONNECTION_CREATED` (24)
|
|
|
|
|
|
|
|
`_AMQ_ConnectionName`, `_AMQ_RemoteAddress`
|
|
|
|
|
|
|
|
- `CONNECTION_DESTROYED` (25)
|
|
|
|
|
|
|
|
`_AMQ_ConnectionName`, `_AMQ_RemoteAddress`
|
|
|
|
|
|
|
|
- `SESSION_CREATED` (26)
|
|
|
|
|
|
|
|
`_AMQ_ConnectionName`, `_AMQ_User`, `_AMQ_SessionName`
|
|
|
|
|
|
|
|
- `SESSION_CLOSED` (27)
|
|
|
|
|
|
|
|
`_AMQ_ConnectionName`, `_AMQ_User`, `_AMQ_SessionName`
|
|
|
|
|
|
|
|
- `MESSAGE_DELIVERED` (28)
|
|
|
|
|
|
|
|
`_AMQ_Address`, `_AMQ_Routing_Type`, `_AMQ_RoutingName`,
|
|
|
|
`_AMQ_ConsumerName`, `_AMQ_Message_ID`
|
|
|
|
|
|
|
|
- `MESSAGE_EXPIRED` (29)
|
|
|
|
|
|
|
|
`_AMQ_Address`, `_AMQ_Routing_Type`, `_AMQ_RoutingName`,
|
|
|
|
`_AMQ_ConsumerName`, `_AMQ_Message_ID`
|
|
|
|
|
2014-12-11 07:17:29 -05:00
|
|
|
## Message Counters
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Message counters can be used to obtain information on queues *over time* as
|
|
|
|
Apache ActiveMQ Artemis keeps a history on queue metrics.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
They can be used to show *trends* 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.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2017-07-31 06:26:28 -04:00
|
|
|
Message counters give additional information about the queues:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `count`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The *total* number of messages added to the queue since the server was
|
|
|
|
started
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `countDelta`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
the number of messages added to the queue *since the last message counter
|
|
|
|
update*
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `messageCount`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The *current* number of messages in the queue
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `messageCountDelta`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The *overall* number of messages added/removed from the queue *since the last
|
|
|
|
message counter update*. For example, if `messageCountDelta` is equal to `-10`
|
|
|
|
this means that overall 10 messages have been removed from the queue (e.g. 2
|
|
|
|
messages were added and 12 were removed)
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
- `lastAddTimestamp`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The timestamp of the last time a message was added to the queue
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2020-09-18 10:34:16 -04:00
|
|
|
- `lastAckTimestamp`
|
|
|
|
|
|
|
|
The timestamp of the last time a message from the queue was acknowledged
|
|
|
|
|
2021-06-03 10:43:11 -04:00
|
|
|
- `updateTimestamp`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
The timestamp of the last message counter update
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
These attributes can be used to determine other meaningful data as well. For
|
|
|
|
example, to know specifically how many messages were *consumed* from the queue
|
|
|
|
since the last update simply subtract the `messageCountDelta` from
|
|
|
|
`countDelta`.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2014-12-11 07:17:29 -05:00
|
|
|
### Configuring Message Counters
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
By default, message counters are disabled as it might have a small negative
|
|
|
|
effect on memory.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
To enable message counters, you can set it to `true` in `broker.xml`:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
```xml
|
|
|
|
<message-counter-enabled>true</message-counter-enabled>
|
|
|
|
```
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
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 `broker.xml`:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
```xml
|
|
|
|
<!-- keep history for a week -->
|
|
|
|
<message-counter-max-day-history>7</message-counter-max-day-history>
|
|
|
|
<!-- sample the queues every minute (60000ms) -->
|
|
|
|
<message-counter-sample-period>60000</message-counter-sample-period>
|
|
|
|
```
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
Message counters can be retrieved using the Management API. For example, to
|
|
|
|
retrieve message counters on a queue using JMX:
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
```java
|
2015-04-27 17:32:30 -04:00
|
|
|
// retrieve a connection to Apache ActiveMQ Artemis's MBeanServer
|
2014-12-11 07:17:29 -05:00
|
|
|
MBeanServerConnection mbsc = ...
|
2017-02-13 16:20:12 -05:00
|
|
|
QueueControlMBean queueControl = (QueueControl)MBeanServerInvocationHandler.newProxyInstance(mbsc,
|
2014-12-11 07:17:29 -05:00
|
|
|
on,
|
2017-02-13 16:20:12 -05:00
|
|
|
QueueControl.class,
|
2014-12-11 07:17:29 -05:00
|
|
|
false);
|
2015-01-23 09:28:07 -05:00
|
|
|
// message counters are retrieved as a JSON String
|
2014-12-11 07:17:29 -05:00
|
|
|
String counters = queueControl.listMessageCounter();
|
|
|
|
// use the MessageCounterInfo helper class to manipulate message counters more easily
|
2015-01-23 09:28:07 -05:00
|
|
|
MessageCounterInfo messageCounter = MessageCounterInfo.fromJSON(counters);
|
2014-12-11 07:17:29 -05:00
|
|
|
System.out.format("%s message(s) in the queue (since last sample: %s)\n",
|
|
|
|
messageCounter.getMessageCount(),
|
|
|
|
messageCounter.getMessageCountDelta());
|
|
|
|
```
|
|
|
|
|
|
|
|
### Example
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2018-03-09 10:07:38 -05:00
|
|
|
See the [Message Counter Example](examples.md#message-counter) which shows how
|
|
|
|
to use message counters to retrieve information on a queue.
|