This commit is contained in:
Justin Bertram 2017-10-18 15:24:44 -05:00
commit cf63187838
17 changed files with 614 additions and 29 deletions

View File

@ -16,6 +16,8 @@
*/
package org.apache.activemq.artemis.core.config;
import java.security.KeyStore;
public class JMXConnectorConfiguration {
private int rmiRegistryPort;
private String connectorHost = "localhost";
@ -27,10 +29,10 @@ public class JMXConnectorConfiguration {
private String objectName = "connector:name=rmi";
private String authenticatorType = "password";
private boolean secured = false;
private String keyStoreProvider;
private String keyStoreProvider = KeyStore.getDefaultType();
private String keyStorePath;
private String keyStorePassword;
private String trustStoreProvider;
private String trustStoreProvider = KeyStore.getDefaultType();
private String trustStorePath;
private String trustStorePassword;

View File

@ -40,27 +40,29 @@ public class JaasAuthenticator implements JMXAuthenticator {
}
@Override
public Subject authenticate(Object credentials) throws SecurityException {
if (!(credentials instanceof String[])) {
throw new IllegalArgumentException("Expected String[2], got "
+ (credentials != null ? credentials.getClass().getName() : null));
}
final String[] params = (String[]) credentials;
if (params.length != 2) {
throw new IllegalArgumentException("Expected String[2] but length was " + params.length);
}
public Subject authenticate(final Object credentials) throws SecurityException {
try {
Subject subject = new Subject();
LoginContext loginContext = new LoginContext(realm, subject, new CallbackHandler() {
LoginContext loginContext = new LoginContext(realm, subject, new CallbackHandler() {
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
/*
* pull out the jmx credentials if they exist if not, guest login module will handle it
* */
String[] params = null;
if (credentials instanceof String[] && ((String[]) credentials).length == 2) {
params = (String[]) credentials;
}
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof NameCallback) {
((NameCallback) callbacks[i]).setName(params[0]);
if (params != null) {
((NameCallback) callbacks[i]).setName(params[0]);
}
} else if (callbacks[i] instanceof PasswordCallback) {
((PasswordCallback) callbacks[i]).setPassword((params[1].toCharArray()));
if (params != null) {
((PasswordCallback) callbacks[i]).setPassword((params[1].toCharArray()));
}
} else {
throw new UnsupportedCallbackException(callbacks[i]);
}
@ -68,12 +70,6 @@ public class JaasAuthenticator implements JMXAuthenticator {
}
});
loginContext.login();
/* if (subject.getPrincipals().size() == 0) {
// there must be some Principals, but which ones required are tested later
throw new FailedLoginException("User does not have the required role");
}*/
return subject;
} catch (LoginException e) {
throw new SecurityException("Authentication failed", e);

View File

@ -404,10 +404,38 @@ using the service url `service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi` and
You can also configure the connector using the following:
- connector-host The host to expose the agent on
- connector-port The port to expose the agent on
- jmx-realm The jmx realm to use for authentication, defaults to `activemq` to match the JAAS configuration.
- object-name The object name to expose the remote connector on, default is `connector:name=rmi`
- connector-host
The host to expose the agent on
- connector-port
The port to expose the agent on
- jmx-realm
The jmx realm to use for authentication, defaults to `activemq` to match the JAAS configuration.
- object-name
The object name to expose the remote connector on, default is `connector:name=rmi`
- secured
Whether the connector is secured using SSL
- key-store-path
The location of the keystore
- key-store-password
The keystore password
- key-store-provider
The provider, JKS by default
- trust-store-path
The location of the truststore
- trust-store-password
The trustore password
- trust-store-provider
The provider, JKS by default
> **Note**
>

View File

@ -0,0 +1,114 @@
<?xml version='1.0'?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.activemq.examples.broker</groupId>
<artifactId>jms-examples</artifactId>
<version>2.4.0-SNAPSHOT</version>
</parent>
<artifactId>jmx-ssl</artifactId>
<packaging>jar</packaging>
<name>ActiveMQ Artemis JMS "JMX over SSL" Example</name>
<properties>
<activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-core-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-client</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-maven-plugin</artifactId>
<executions>
<execution>
<id>create</id>
<goals>
<goal>create</goal>
</goals>
<configuration>
<ignore>${noServer}</ignore>
<javaOptions>-Djava.rmi.server.hostname=localhost</javaOptions>
</configuration>
</execution>
<execution>
<id>start</id>
<goals>
<goal>cli</goal>
</goals>
<configuration>
<ignore>${noServer}</ignore>
<spawn>true</spawn>
<testURI>tcp://localhost:61616</testURI>
<args>
<param>run</param>
</args>
</configuration>
</execution>
<execution>
<id>runClient</id>
<goals>
<goal>runClient</goal>
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.JMXExample</clientClass>
</configuration>
</execution>
<execution>
<id>stop</id>
<goals>
<goal>cli</goal>
</goals>
<configuration>
<ignore>${noServer}</ignore>
<args>
<param>stop</param>
</args>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.activemq.examples.broker</groupId>
<artifactId>jmx</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,176 @@
<!--
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.
-->
<html>
<head>
<title>ActiveMQ Artemis JMX SSL Management Example</title>
<link rel="stylesheet" type="text/css" href="../../../common/common.css" />
<link rel="stylesheet" type="text/css" href="../../../common/prettify.css" />
<script type="text/javascript" src="../../../common/prettify.js"></script>
</head>
<body onload="prettyPrint()">
<h1>JMX Management Example</h1>
<pre>To run the example, simply type <b>mvn verify -Djavax.net.ssl.keyStore=target/server0/etc/activemq.example.keystore -Djavax.net.ssl.keyStorePassword=activemqexample -Djavax.net.ssl.trustStore=target/server0/etc/activemq.example.truststore -Djavax.net.ssl.trustStorePassword=activemqexample</b> from this directory, <br>or add <b>-PnoServer</b> if you want to start and create the server manually.</pre>
<p>This example shows how to manage ActiveMQ Artemis using <a href="http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/">JMX using SSL</a></p>
<h2>Example configuration</h2>
<p>ActiveMQ Artemis exposes its managed resources by default on the platform MBeanServer.</p>
<p>To access this MBeanServer remotely, add the following to the management.xml configuration:
<pre class="prettyprint">
<code><connector connector-port="1099" connector-host="localhost"/></code>
</pre>
<p>With these properties, ActiveMQ Artemis server will be manageable remotely using standard JMX URL on port <code>1099</code>.</p>
</p>
<h2>Example step-by-step</h2>
<ol>
<li>First we need to get an initial context so we can look-up the JMS connection factory and destination objects from JNDI. This initial context will get its properties from <a href="server0/client-jndi.properties">client-jndi.properties</a></li>
<pre class="prettyprint">
<code>InitialContext initialContext = getContext(0);</code>
</pre>
<li>We look up the JMS queue object from JNDI</li>
<pre class="prettyprint">
<code>Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");</code>
</pre>
<li>We look up the JMS connection factory object from JNDI</li>
<pre class="prettyprint">
<code>ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");</code>
</pre>
<li>We create a JMS connection</li>
<pre class="prettyprint">
<code>connection = cf.createConnection();</code>
</pre>
<li>We create a JMS session. The session is created as non transacted and will auto acknowledge messages.</li>
<pre class="prettyprint">
<code>Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);</code>
</pre>
<li>We create a JMS message producer on the session. This will be used to send the messages.</li>
<pre class="prettyprint">
<code>MessageProducer messageProducer = session.createProducer(topic);</code>
</pre>
<li>We create a JMS text message that we are going to send.</li>
<pre class="prettyprint">
<code>TextMessage message = session.createTextMessage("This is a text message");</code>
</pre>
<li>We send message to the queue</li>
<pre class="prettyprint">
<code>messageProducer.send(message);</code>
</pre>
<p><em>Now that we have a message in the queue, we will manage the queue by retrieving the number of messages in the queue
(i.e. 1) and by removing the message which has been sent in step 8.</em></p>
<li>We retrieve the <code>ObjectName</code> corresponding to the queue using a helper class <code>ObjectNameBuilder</code></li>
<pre class="prettyprint">
<code>ObjectName on = ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queue.getQueueName());</code>
</pre>
<li>We create a JMX Connector to connect to the server's MBeanServer using the <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html#gdevg">standard JMX service URL</a></li>
<pre class="prettyprint">
<code>JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMX_URL), new HashMap());</code>
</pre>
<li>We retrieve a <code>MBeanServerConnection</code> from the JMX connector</li>
<pre class="prettyprint">
<code>TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);</code>
</pre>
<li>We create a <code>JMSQueueControl</code> proxy to manage the queue on the server</li>
<pre class="prettyprint">
<code>JMSQueueControl queueControl = (JMSQueueControl)MBeanServerInvocationHandler.newProxyInstance(mbsc,
on,
JMSQueueControl.class,
false);
</code>
</pre>
<li>We use this mbean proxy to retrieve the number of messages in the queue using the <code>getMessageCount</code> method</li>
<pre class="prettyprint">
<code>System.out.println(queueControl.getName() + " contains " + queueControl.getMessageCount() + " messages");</code>
</pre>
<li>We will now remove the message sent at step 8 using the <code>removeMessage</code> method with the JMS Message ID of the message</li>
<pre class="prettyprint">
<code>System.out.println("message has been removed: " + queueControl.removeMessage(message.getJMSMessageID()));</code>
</pre>
<li>We use again the mbean proxy to retrieve the number of messages. This time, it will display <code>0</code> messages</li>
<pre class="prettyprint">
<code>System.out.println(queueControl.getName() + " contains " + queueControl.getMessageCount() + " messages");</code>
</pre>
<li>Now we have finish the management operations, we close the JMX connector</li>
<pre class="prettyprint">
<code>connector.close()</code>
</pre>
<p><em>We will now try to consume the message sent to the queue but it won't be there: it has been removed by the management operation</em></p>
<li>We create a JMS message consumer on the queue</li>
<pre class="prettyprint">
<code>MessageConsumer messageConsumer = session.createConsumer(queue);</code>
</pre>
<li>We start the connection. In order for delivery to occur on any consumers or subscribers on a connection, the connection must be started</li>
<pre class="prettyprint">
<code>connection.start();</code>
</pre>
<li>We try to receive a message from the queue. Since there is none, the call will timeout after 5000ms and messageReceived will be null
</li>
<pre class="prettyprint">
<code>TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
System.out.println("Received message: " + messageReceived);</code>
</pre>
<li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
<pre class="prettyprint">
<code>finally
{
if (initialContext != null)
{
initialContext.close();
}
if (connection != null)
{
connection.close();
}
}</code>
</pre>
</ol>
<h2>More information</h2>
<ul>
<li>User Manual's <a href="../../../docs/user-manual/en/html_single/index.html#management.jmx">Using Management Via JMX chapter</a></li>
<li><a href="http://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html">Java management guide</a></li>
</ul>
</body>
</html>

View File

@ -0,0 +1,127 @@
/*
* 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.
*/
package org.apache.activemq.artemis.jms.example;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.naming.InitialContext;
import java.util.HashMap;
import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
import org.apache.activemq.artemis.api.core.management.QueueControl;
import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage;
/**
* An example that shows how to manage ActiveMQ Artemis using JMX.
*/
public class JMXExample {
private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi";
public static void main(final String[] args) throws Exception {
QueueConnection connection = null;
InitialContext initialContext = null;
try {
// Step 1. Create an initial context to perform the JNDI lookup.
initialContext = new InitialContext();
// Step 2. Perfom a lookup on the queue
Queue queue = (Queue) initialContext.lookup("queue/exampleQueue");
// Step 3. Perform a lookup on the Connection Factory
QueueConnectionFactory cf = (QueueConnectionFactory) initialContext.lookup("ConnectionFactory");
// Step 4.Create a JMS Connection
connection = cf.createQueueConnection();
// Step 5. Create a JMS Session
QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
// Step 6. Create a JMS Message Producer
MessageProducer producer = session.createProducer(queue);
// Step 7. Create a Text Message
TextMessage message = session.createTextMessage("This is a text message");
System.out.println("Sent message: " + message.getText());
// Step 8. Send the Message
producer.send(message);
// Step 9. Retrieve the ObjectName of the queue. This is used to identify the server resources to manage
ObjectName on = ObjectNameBuilder.DEFAULT.getQueueObjectName(SimpleString.toSimpleString(queue.getQueueName()), SimpleString.toSimpleString(queue.getQueueName()), RoutingType.ANYCAST);
// Step 10. Create JMX Connector to connect to the server's MBeanServer
//we dont actually need credentials as the guest login i sused but this is how its done
HashMap env = new HashMap();
String[] creds = {"guest", "guest"};
env.put(JMXConnector.CREDENTIALS, creds);
JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMXExample.JMX_URL), env);
// Step 11. Retrieve the MBeanServerConnection
MBeanServerConnection mbsc = connector.getMBeanServerConnection();
// Step 12. Create a QueueControl proxy to manage the queue on the server
QueueControl queueControl = MBeanServerInvocationHandler.newProxyInstance(mbsc, on, QueueControl.class, false);
// Step 13. Display the number of messages in the queue
System.out.println(queueControl.getName() + " contains " + queueControl.getMessageCount() + " messages");
// Step 14. Remove the message sent at step #8
System.out.println("message has been removed: " + queueControl.removeMessage(((ActiveMQTextMessage) message).getCoreMessage().getMessageID()));
// Step 15. Display the number of messages in the queue
System.out.println(queueControl.getName() + " contains " + queueControl.getMessageCount() + " messages");
// Step 16. We close the JMX connector
connector.close();
// Step 17. Create a JMS Message Consumer on the queue
MessageConsumer messageConsumer = session.createConsumer(queue);
// Step 18. Start the Connection
connection.start();
// Step 19. Trying to receive a message. Since the only message in the queue was removed by a management
// operation, there is none to consume.
// The call will timeout after 5000ms and messageReceived will be null
TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
System.out.println("Received message: " + messageReceived);
} finally {
// Step 20. Be sure to close the resources!
if (initialContext != null) {
initialContext.close();
}
if (connection != null) {
connection.close();
}
}
}
}

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
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.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
<core xmlns="urn:activemq:core">
<bindings-directory>./data/messaging/bindings</bindings-directory>
<journal-directory>./data/messaging/journal</journal-directory>
<large-messages-directory>./data/messaging/largemessages</large-messages-directory>
<paging-directory>./data/messaging/paging</paging-directory>
<!-- true to expose ActiveMQ Artemis resources through JMX -->
<jmx-management-enabled>true</jmx-management-enabled>
<!-- Acceptors -->
<acceptors>
<acceptor name="netty">tcp://localhost:61616</acceptor>
</acceptors>
<!-- Other config -->
<security-settings>
<!--security for example queue-->
<security-setting match="exampleQueue">
<permission roles="guest" type="createDurableQueue"/>
<permission roles="guest" type="deleteDurableQueue"/>
<permission roles="guest" type="createNonDurableQueue"/>
<permission roles="guest" type="deleteNonDurableQueue"/>
<permission roles="guest" type="consume"/>
<permission roles="guest" type="send"/>
</security-setting>
</security-settings>
<addresses>
<address name="exampleQueue">
<anycast>
<queue name="exampleQueue"/>
</anycast>
</address>
</addresses>
</core>
</configuration>

View File

@ -0,0 +1,56 @@
<?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.org/schema">
<connector
connector-port="1099"
connector-host="localhost"
secured="true"
key-store-path="${data.dir}/../etc/activemq.example.keystore"
key-store-password="activemqexample"
trust-store-path="${data.dir}/../etc/activemq.example.truststore"
trust-store-password="activemqexample"/>
<authorisation>
<whitelist>
<entry domain="hawtio"/>
</whitelist>
<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.apache">
<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.apache" 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

@ -0,0 +1,20 @@
# 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.
java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
connectionFactory.ConnectionFactory=tcp://localhost:61616
queue.queue/exampleQueue=exampleQueue

View File

@ -61,6 +61,7 @@ under the License.
</goals>
<configuration>
<ignore>${noServer}</ignore>
<javaOptions>-Djava.rmi.server.hostname=localhost</javaOptions>
</configuration>
</execution>
<execution>
@ -69,7 +70,6 @@ under the License.
<goal>cli</goal>
</goals>
<configuration>
<debug>true</debug>
<ignore>${noServer}</ignore>
<spawn>true</spawn>
<testURI>tcp://localhost:61616</testURI>

View File

@ -36,9 +36,8 @@ under the License.
<p>ActiveMQ Artemis exposes its managed resources by default on the platform MBeanServer.</p>
<p>To access this MBeanServer remotely, add the following to the management.xml configuration:
<pre class="prettyprint">
<code><connector connector-port="1099" connector-host="127.0.0.1"/></code>
<code><connector connector-port="1099" connector-host="localhost"/></code>
</pre>
<p>If the example does not work then try changing the host to the ip address of the machine running this example on</p>
<p>With these properties, ActiveMQ Artemis server will be manageable remotely using standard JMX URL on port <code>1099</code>.</p>
</p>

View File

@ -79,6 +79,7 @@ public class JMXExample {
ObjectName on = ObjectNameBuilder.DEFAULT.getQueueObjectName(SimpleString.toSimpleString(queue.getQueueName()), SimpleString.toSimpleString(queue.getQueueName()), RoutingType.ANYCAST);
// Step 10. Create JMX Connector to connect to the server's MBeanServer
//we dont actually need credentials as the guest login i sused but this is how its done
HashMap env = new HashMap();
String[] creds = {"guest", "guest"};
env.put(JMXConnector.CREDENTIALS, creds);

View File

@ -16,7 +16,7 @@
~ limitations under the License.
-->
<management-context xmlns="http://activemq.org/schema">
<connector connector-port="1099" connector-host="127.0.0.1"/>
<connector connector-port="1099" connector-host="localhost"/>
<authorisation>
<whitelist>
<entry domain="hawtio"/>

View File

@ -61,6 +61,7 @@ under the License.
</goals>
<configuration>
<ignore>${noServer}</ignore>
<javaOptions>-Djava.rmi.server.hostname=localhost</javaOptions>
</configuration>
</execution>
<execution>

View File

@ -75,6 +75,7 @@ public class MessageCounterExample {
// Step 7. Use JMX to retrieve the message counters using the JMSQueueControl
ObjectName on = ObjectNameBuilder.DEFAULT.getQueueObjectName(SimpleString.toSimpleString(queue.getQueueName()), SimpleString.toSimpleString(queue.getQueueName()), RoutingType.ANYCAST);
//we dont actually need credentials as the guest login i sused but this is how its done
HashMap env = new HashMap();
String[] creds = {"guest", "guest"};
env.put(JMXConnector.CREDENTIALS, creds);