From de52d4e20e98542b85595297272e51eb8f20202f Mon Sep 17 00:00:00 2001
From: Andy Taylor
Date: Wed, 18 Oct 2017 09:58:39 +0100
Subject: [PATCH] ARTEMIS-1463 - added SSL example + docs
also added support for anon login
https://issues.apache.org/jira/browse/ARTEMIS-1463
---
.../config/JMXConnectorConfiguration.java | 6 +-
.../server/management/JaasAuthenticator.java | 34 ++--
docs/user-manual/en/management.md | 36 +++-
examples/features/standard/jmx-ssl/pom.xml | 114 ++++++++++++
.../features/standard/jmx-ssl/readme.html | 176 ++++++++++++++++++
.../artemis/jms/example/JMXExample.java | 127 +++++++++++++
.../server0/activemq.example.keystore | Bin 0 -> 1273 bytes
.../server0/activemq.example.truststore | Bin 0 -> 866 bytes
.../resources/activemq/server0/broker.xml | 64 +++++++
.../resources/activemq/server0/management.xml | 56 ++++++
.../src/main/resources/jndi.properties | 20 ++
examples/features/standard/jmx/pom.xml | 2 +-
examples/features/standard/jmx/readme.html | 3 +-
.../artemis/jms/example/JMXExample.java | 1 +
.../resources/activemq/server0/management.xml | 2 +-
.../standard/message-counters/pom.xml | 1 +
.../jms/example/MessageCounterExample.java | 1 +
17 files changed, 614 insertions(+), 29 deletions(-)
create mode 100644 examples/features/standard/jmx-ssl/pom.xml
create mode 100644 examples/features/standard/jmx-ssl/readme.html
create mode 100644 examples/features/standard/jmx-ssl/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java
create mode 100644 examples/features/standard/jmx-ssl/src/main/resources/activemq/server0/activemq.example.keystore
create mode 100644 examples/features/standard/jmx-ssl/src/main/resources/activemq/server0/activemq.example.truststore
create mode 100644 examples/features/standard/jmx-ssl/src/main/resources/activemq/server0/broker.xml
create mode 100644 examples/features/standard/jmx-ssl/src/main/resources/activemq/server0/management.xml
create mode 100644 examples/features/standard/jmx-ssl/src/main/resources/jndi.properties
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/JMXConnectorConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/JMXConnectorConfiguration.java
index 786f55415d4..b47acf53639 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/JMXConnectorConfiguration.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/JMXConnectorConfiguration.java
@@ -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;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/JaasAuthenticator.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/JaasAuthenticator.java
index 23167e909f2..739392ae737 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/JaasAuthenticator.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/JaasAuthenticator.java
@@ -40,27 +40,29 @@ public void setRealm(String realm) {
}
@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 void handle(Callback[] callbacks) throws IOException, UnsupportedCallback
}
});
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);
diff --git a/docs/user-manual/en/management.md b/docs/user-manual/en/management.md
index 9587d050640..34a2f4583f8 100644
--- a/docs/user-manual/en/management.md
+++ b/docs/user-manual/en/management.md
@@ -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**
>
diff --git a/examples/features/standard/jmx-ssl/pom.xml b/examples/features/standard/jmx-ssl/pom.xml
new file mode 100644
index 00000000000..04e7be97dbd
--- /dev/null
+++ b/examples/features/standard/jmx-ssl/pom.xml
@@ -0,0 +1,114 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache.activemq.examples.broker
+ jms-examples
+ 2.4.0-SNAPSHOT
+
+
+ jmx-ssl
+ jar
+ ActiveMQ Artemis JMS "JMX over SSL" Example
+
+
+ ${project.basedir}/../../../..
+
+
+
+
+ org.apache.activemq
+ artemis-core-client
+ ${project.version}
+
+
+ org.apache.activemq
+ artemis-jms-client
+ ${project.version}
+
+
+
+
+
+
+ org.apache.activemq
+ artemis-maven-plugin
+
+
+ create
+
+ create
+
+
+ ${noServer}
+ -Djava.rmi.server.hostname=localhost
+
+
+
+ start
+
+ cli
+
+
+ ${noServer}
+ true
+ tcp://localhost:61616
+
+ run
+
+
+
+
+ runClient
+
+ runClient
+
+
+ org.apache.activemq.artemis.jms.example.JMXExample
+
+
+
+ stop
+
+ cli
+
+
+ ${noServer}
+
+ stop
+
+
+
+
+
+
+ org.apache.activemq.examples.broker
+ jmx
+ ${project.version}
+
+
+
+
+
+
+
diff --git a/examples/features/standard/jmx-ssl/readme.html b/examples/features/standard/jmx-ssl/readme.html
new file mode 100644
index 00000000000..ca4e6dafb85
--- /dev/null
+++ b/examples/features/standard/jmx-ssl/readme.html
@@ -0,0 +1,176 @@
+
+
+
+
+ ActiveMQ Artemis JMX SSL Management Example
+
+
+
+
+
+
JMX Management Example
+
+
To run the example, simply type 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 from this directory, or add -PnoServer if you want to start and create the server manually.
+
+
This example shows how to manage ActiveMQ Artemis using JMX using SSL
+
+
Example configuration
+
+
ActiveMQ Artemis exposes its managed resources by default on the platform MBeanServer.
+
To access this MBeanServer remotely, add the following to the management.xml configuration:
+
+
+
+
With these properties, ActiveMQ Artemis server will be manageable remotely using standard JMX URL on port 1099.
+
+
+
Example step-by-step
+
+
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 client-jndi.properties
We create a JMS text message that we are going to send.
+
+ TextMessage message = session.createTextMessage("This is a text message");
+
+
+
We send message to the queue
+
+ messageProducer.send(message);
+
+
+
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.
+
+
We retrieve the ObjectName corresponding to the queue using a helper class ObjectNameBuilder
+
+ ObjectName on = ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queue.getQueueName());
+
+
+
We create a JMX Connector to connect to the server's MBeanServer using the standard JMX service URL
+
+ JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMX_URL), new HashMap());
+
+
+
We retrieve a MBeanServerConnection from the JMX connector
And finally, always remember to close your JMS connections and resources after use, in a finally block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects
+
+
diff --git a/examples/features/standard/jmx-ssl/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java b/examples/features/standard/jmx-ssl/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java
new file mode 100644
index 00000000000..9223a5ed28c
--- /dev/null
+++ b/examples/features/standard/jmx-ssl/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java
@@ -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();
+ }
+ }
+ }
+}
diff --git a/examples/features/standard/jmx-ssl/src/main/resources/activemq/server0/activemq.example.keystore b/examples/features/standard/jmx-ssl/src/main/resources/activemq/server0/activemq.example.keystore
new file mode 100644
index 0000000000000000000000000000000000000000..50de6819eee906dd605e2f63695080cb6c46b1a6
GIT binary patch
literal 1273
zcmezO_TO6u1_mY|W&~r_+{*0KN+8e6@Yg;$Al+}!#Mo`X$Ht}2#>m2`#U#kc$jZRd
z#8@tO^zZg=HOI(F2mG}dwA39uKTDsmd~$X9GIL4(t6MK9El^pV(D5Qfe(jFGpC`CE
z-Om1}zG|}W5rv8Ox|3F<7+F*wxOn^%&WTH
z?MiAx@AU=Bq*OnRU2B-b7r~dcFLc{|X0;0+Dz0o`e)A!ZO=hd$rovhO+RAJ-8gJ-*
z&|+hfQ;Y6+J^OK2`v0X*@HnhH
zwDwp0CZC*CPraq9PTDek63AQQvf=#>*^L`D#UlUyO|SCGzQp?3#Z%)+L5697s^ZI}
zi;Z_Wgd7-57B>Hs$gUA#@m_0s?V96`#Ud0pV790BN0=w{HamP@;
zd&e*SoSl8<_NB%d&;4!XDrSWy=y@p|nwjljdgE&R7S3}E!v%#SW-iJtU`udSjIWB2
zUlO~qwC=*D`iCb^Et)9ztKr^}qsPLdPU?MgnKYy4a$Le3j>#pNWvM^~P$6ziA!dY-ft)z6p^2f9p@D&sp{bEk6p(9bU<~Kd
z#SKl2+kq)n2j+D~AV;35v610#eQ={}sgP#SeXlusZ=O8=Cb&Jw=DiEUVLAJTZGmc;
zuCWeEfxjbddn11BKl*i-!MD@1LvyY-S~tj=+HZ6MH!u=sa<}1i)-ybe$y*AtS-swH7W6XAh@2s4%e)lh{S4}^|
zeYkDeo6-X#!~1q!iS&O~$S%;>u*FlXQ2B+AhM4g7^PEOKCzd_55v%GBsp-{tuy~!E
z_U2`!6Z00=bN^B_P5Ssdsftm>`plA#`&I-_=v>i!|6$bA`D~NA)8ZPcLse54eXReT
z_tau;Y++z(Y_PHA37RIDuhwqHF6#HfWsknj*DKE2A6NfnTK$n{uZQl#iO;>~@t$E~
zpPZj@NycFk>-x2(cLW~AZ=EM`VPp60t5!@2M{Kw0X2q5YniS;cxSwHc$&LG#(ZO5r
zGU?>>=U*R}m!9R6jVi9)`rbs?*5+~V8~47Z%CM;SN9z3_@HR|btY{!_APY=+vV1IJ
zEFvNrtvfq}wnw|H`ttYf0>6#bQ}&yqBxz=S1_K=?5fAs27iaR)x^(Y&2#C(pNo3;h
x_|7B}&vUW9WOl?(+sGsXPVJ(Gn(&D4^*Or=1hy~WWr)>___poMkE?BSxB=sr?Kl7c
literal 0
HcmV?d00001
diff --git a/examples/features/standard/jmx-ssl/src/main/resources/activemq/server0/activemq.example.truststore b/examples/features/standard/jmx-ssl/src/main/resources/activemq/server0/activemq.example.truststore
new file mode 100644
index 0000000000000000000000000000000000000000..129391a94858610c3384fbdff9827d8075213682
GIT binary patch
literal 866
zcmezO_TO6u1_mY|W(3o$xs}>IWPs%5&yIw%GH
zj$DTEYrX%Z#4I`Yq6gz~CQ*jz2?710
z%G_r*P1@PC=yePChX|RkAg6tQxS;jgY}fxLk%Fy+bev52vVh-kF#
z>=4=>?Xv32-?t0=HdasBZ;q0rne`bAbeKdu+*4kh$xG|fz2hMuI!`B&iNE7JlSn+z
s#rl%j5j$-olMFbuiyCUeBfh`(j8*u!GNY&YvgIk`13r(>t`B_x0CFfZL;wH)
literal 0
HcmV?d00001
diff --git a/examples/features/standard/jmx-ssl/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/jmx-ssl/src/main/resources/activemq/server0/broker.xml
new file mode 100644
index 00000000000..7576376219c
--- /dev/null
+++ b/examples/features/standard/jmx-ssl/src/main/resources/activemq/server0/broker.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+ ./data/messaging/bindings
+
+ ./data/messaging/journal
+
+ ./data/messaging/largemessages
+
+ ./data/messaging/paging
+
+
+
+ true
+
+
+
+ tcp://localhost:61616
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/features/standard/jmx-ssl/src/main/resources/activemq/server0/management.xml b/examples/features/standard/jmx-ssl/src/main/resources/activemq/server0/management.xml
new file mode 100644
index 00000000000..9d31f6a1b46
--- /dev/null
+++ b/examples/features/standard/jmx-ssl/src/main/resources/activemq/server0/management.xml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/features/standard/jmx-ssl/src/main/resources/jndi.properties b/examples/features/standard/jmx-ssl/src/main/resources/jndi.properties
new file mode 100644
index 00000000000..93537c415a9
--- /dev/null
+++ b/examples/features/standard/jmx-ssl/src/main/resources/jndi.properties
@@ -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
diff --git a/examples/features/standard/jmx/pom.xml b/examples/features/standard/jmx/pom.xml
index f78c1f3f61e..bca7105f691 100644
--- a/examples/features/standard/jmx/pom.xml
+++ b/examples/features/standard/jmx/pom.xml
@@ -61,6 +61,7 @@ under the License.
${noServer}
+ -Djava.rmi.server.hostname=localhost
@@ -69,7 +70,6 @@ under the License.
cli
- true${noServer}truetcp://localhost:61616
diff --git a/examples/features/standard/jmx/readme.html b/examples/features/standard/jmx/readme.html
index fe981c60e54..7106e343028 100644
--- a/examples/features/standard/jmx/readme.html
+++ b/examples/features/standard/jmx/readme.html
@@ -36,9 +36,8 @@
Example configuration
ActiveMQ Artemis exposes its managed resources by default on the platform MBeanServer.
To access this MBeanServer remotely, add the following to the management.xml configuration:
-
+
-
If the example does not work then try changing the host to the ip address of the machine running this example on
With these properties, ActiveMQ Artemis server will be manageable remotely using standard JMX URL on port 1099.
diff --git a/examples/features/standard/jmx/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java b/examples/features/standard/jmx/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java
index b59f4198485..9223a5ed28c 100644
--- a/examples/features/standard/jmx/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java
+++ b/examples/features/standard/jmx/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java
@@ -79,6 +79,7 @@ public static void main(final String[] args) throws Exception {
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);
diff --git a/examples/features/standard/jmx/src/main/resources/activemq/server0/management.xml b/examples/features/standard/jmx/src/main/resources/activemq/server0/management.xml
index 182bb1f9537..86d29a1fe3a 100644
--- a/examples/features/standard/jmx/src/main/resources/activemq/server0/management.xml
+++ b/examples/features/standard/jmx/src/main/resources/activemq/server0/management.xml
@@ -16,7 +16,7 @@
~ limitations under the License.
-->
-
+
diff --git a/examples/features/standard/message-counters/pom.xml b/examples/features/standard/message-counters/pom.xml
index 8f745a3cc96..d30d90bbd68 100644
--- a/examples/features/standard/message-counters/pom.xml
+++ b/examples/features/standard/message-counters/pom.xml
@@ -61,6 +61,7 @@ under the License.
${noServer}
+ -Djava.rmi.server.hostname=localhost
diff --git a/examples/features/standard/message-counters/src/main/java/org/apache/activemq/artemis/jms/example/MessageCounterExample.java b/examples/features/standard/message-counters/src/main/java/org/apache/activemq/artemis/jms/example/MessageCounterExample.java
index 16947d17079..0a8dadce215 100644
--- a/examples/features/standard/message-counters/src/main/java/org/apache/activemq/artemis/jms/example/MessageCounterExample.java
+++ b/examples/features/standard/message-counters/src/main/java/org/apache/activemq/artemis/jms/example/MessageCounterExample.java
@@ -75,6 +75,7 @@ public static void main(final String[] args) throws Exception {
// 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);