ARTEMIS-4409 update examples to use management.xml

This commit is contained in:
Justin Bertram 2023-08-30 11:13:07 -05:00
parent 691771c766
commit 75c995198e
7 changed files with 103 additions and 23 deletions

View File

@ -56,9 +56,7 @@ under the License.
</goals> </goals>
<configuration> <configuration>
<ignore>${noServer}</ignore> <ignore>${noServer}</ignore>
<!-- options used for JMX on the example --> <javaOptions>-Djava.rmi.server.hostname=localhost</javaOptions>
<javaOptions>-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=3000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
</javaOptions>
</configuration> </configuration>
</execution> </execution>
<execution> <execution>

View File

@ -4,19 +4,4 @@ To run the example, simply type **mvn verify** from this directory, or **mvn -Pn
This example shows how to kick off a client connected to ActiveMQ using [JMX](http://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html) This example shows how to kick off a client connected to ActiveMQ using [JMX](http://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html)
The example will connect to ActiveMQ Artemis. Using JMX, we will list the remote addresses connected to the broker and close the corresponding connections. The client will be kicked off from ActiveMQ Artemis receiving an exception that its JMS connection was interrupted. The example will connect to ActiveMQ Artemis. Using JMX, we will list the remote addresses connected to the broker and close the corresponding connections. The client will be kicked off from ActiveMQ Artemis receiving an exception that its JMS connection was interrupted.
## Example configuration
ActiveMQ Artemis exposes its managed resources by default on the platform MBeanServer.
To access this MBeanServer remotely, the Java Virtual machine must be started with system properties:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=3000
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
These properties are explained in the Java [management guide](https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html#gdenl) (please note that for this example, we will disable user authentication for simplicity).
With these properties, ActiveMQ Artemis broker will be manageable remotely using standard JMX URL on port `3000`.

View File

@ -38,7 +38,7 @@ import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
*/ */
public class ClientKickoffExample { public class ClientKickoffExample {
private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi"; private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi";
public static void main(final String[] args) throws Exception { public static void main(final String[] args) throws Exception {
QueueConnection connection = null; QueueConnection connection = null;

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<management-context xmlns="http://activemq.apache.org/schema">
<connector connector-port="1099" connector-host="localhost"/>
<authorisation>
<allowlist>
<entry domain="hawtio"/>
</allowlist>
<default-access>
<access method="list*" roles="view,update,amq,guest"/>
<access method="get*" roles="view,update,amq,guest"/>
<access method="is*" roles="view,update,amq,guest"/>
<access method="set*" roles="update,amq,guest"/>
<access method="*" roles="amq,guest"/>
</default-access>
<role-access>
<match domain="org.apache.activemq.artemis">
<access method="list*" roles="view,update,amq,guest"/>
<access method="get*" roles="view,update,amq,guest"/>
<access method="is*" roles="view,update,amq,guest"/>
<access method="set*" roles="update,amq,guest"/>
<access method="*" roles="amq,guest"/>
</match>
<!--example of how to configure a specific object-->
<!--<match domain="org.apache.activemq.artemis" key="subcomponent=queues">
<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>-->
</role-access>
</authorisation>
</management-context>

View File

@ -55,9 +55,8 @@ under the License.
<goal>create</goal> <goal>create</goal>
</goals> </goals>
<configuration> <configuration>
<javaOptions>-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=3001 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
</javaOptions>
<ignore>${noServer}</ignore> <ignore>${noServer}</ignore>
<javaOptions>-Djava.rmi.server.hostname=localhost</javaOptions>
</configuration> </configuration>
</execution> </execution>
<execution> <execution>

View File

@ -48,7 +48,7 @@ import org.apache.activemq.artemis.utils.UUIDGenerator;
*/ */
public class XAHeuristicExample { public class XAHeuristicExample {
private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:3001/jmxrmi"; private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi";
public static void main(final String[] args) throws Exception { public static void main(final String[] args) throws Exception {
Boolean result = true; Boolean result = true;

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<management-context xmlns="http://activemq.apache.org/schema">
<connector connector-port="1099" connector-host="localhost"/>
<authorisation>
<allowlist>
<entry domain="hawtio"/>
</allowlist>
<default-access>
<access method="list*" roles="view,update,amq,guest"/>
<access method="get*" roles="view,update,amq,guest"/>
<access method="is*" roles="view,update,amq,guest"/>
<access method="set*" roles="update,amq,guest"/>
<access method="*" roles="amq,guest"/>
</default-access>
<role-access>
<match domain="org.apache.activemq.artemis">
<access method="list*" roles="view,update,amq,guest"/>
<access method="get*" roles="view,update,amq,guest"/>
<access method="is*" roles="view,update,amq,guest"/>
<access method="set*" roles="update,amq,guest"/>
<access method="*" roles="amq,guest"/>
</match>
<!--example of how to configure a specific object-->
<!--<match domain="org.apache.activemq.artemis" key="subcomponent=queues">
<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>-->
</role-access>
</authorisation>
</management-context>