diff --git a/examples/features/standard/jmx-ssl/pom.xml b/examples/features/standard/jmx-ssl/pom.xml
index b946d70108..8e4a993e55 100644
--- a/examples/features/standard/jmx-ssl/pom.xml
+++ b/examples/features/standard/jmx-ssl/pom.xml
@@ -84,7 +84,10 @@ under the License.
runClient
- org.apache.activemq.artemis.jms.example.JMXExample
+
+ ${project.build.outputDirectory}/activemq/server0/
+
+ org.apache.activemq.artemis.jms.example.JMXOverSSLExample
@@ -103,7 +106,7 @@ under the License.
org.apache.activemq.examples.broker
- jmx
+ jmx-ssl
${project.version}
diff --git a/examples/features/standard/jmx-ssl/readme.md b/examples/features/standard/jmx-ssl/readme.md
index 2951564884..e65301285f 100644
--- a/examples/features/standard/jmx-ssl/readme.md
+++ b/examples/features/standard/jmx-ssl/readme.md
@@ -1,12 +1,8 @@
# 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
+To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually.
-from this directory, or add **-PnoServer** if you want to start and create the broker manually.
-
-This example shows how to manage ActiveMQ Artemis using [JMX using SSL](http://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html)
+This example shows how to manage ActiveMQ Artemis using [JMX over SSL](http://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html)
## Example configuration
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/JMXOverSSLExample.java
similarity index 90%
rename from examples/features/standard/jmx-ssl/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java
rename to examples/features/standard/jmx-ssl/src/main/java/org/apache/activemq/artemis/jms/example/JMXOverSSLExample.java
index 9223a5ed28..b8b8ef7ec9 100644
--- 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/JMXOverSSLExample.java
@@ -37,12 +37,11 @@ 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 {
+public class JMXOverSSLExample {
private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi";
@@ -84,7 +83,12 @@ public class JMXExample {
String[] creds = {"guest", "guest"};
env.put(JMXConnector.CREDENTIALS, creds);
- JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMXExample.JMX_URL), env);
+ System.setProperty("javax.net.ssl.trustStore", args[0] + "activemq.example.truststore");
+ System.setProperty("javax.net.ssl.trustStorePassword", "activemqexample");
+ System.setProperty("javax.net.ssl.keyStore", args[0] + "activemq.example.keystore");
+ System.setProperty("javax.net.ssl.keyStorePassword", "activemqexample");
+
+ JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMXOverSSLExample.JMX_URL), env);
// Step 11. Retrieve the MBeanServerConnection
MBeanServerConnection mbsc = connector.getMBeanServerConnection();
@@ -95,7 +99,7 @@ public class JMXExample {
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()));
+ System.out.println("message has been removed: " + queueControl.removeMessages(null));
// Step 15. Display the number of messages in the queue
System.out.println(queueControl.getName() + " contains " + queueControl.getMessageCount() + " messages");
@@ -113,6 +117,11 @@ public class JMXExample {
// operation, there is none to consume.
// The call will timeout after 5000ms and messageReceived will be null
TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
+
+ if (messageReceived != null) {
+ throw new IllegalStateException("message should be null!");
+ }
+
System.out.println("Received message: " + messageReceived);
} finally {
// Step 20. Be sure to close the resources!
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 9223a5ed28..d6548c7523 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
@@ -37,7 +37,6 @@ 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.
@@ -95,7 +94,7 @@ public class JMXExample {
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()));
+ System.out.println("message has been removed: " + queueControl.removeMessages(null));
// Step 15. Display the number of messages in the queue
System.out.println(queueControl.getName() + " contains " + queueControl.getMessageCount() + " messages");
@@ -113,6 +112,11 @@ public class JMXExample {
// operation, there is none to consume.
// The call will timeout after 5000ms and messageReceived will be null
TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
+
+ if (messageReceived != null) {
+ throw new IllegalStateException("message should be null!");
+ }
+
System.out.println("Received message: " + messageReceived);
} finally {
// Step 20. Be sure to close the resources!
diff --git a/examples/features/standard/pom.xml b/examples/features/standard/pom.xml
index b4d0f675aa..0d4b2f8b03 100644
--- a/examples/features/standard/pom.xml
+++ b/examples/features/standard/pom.xml
@@ -67,6 +67,7 @@ under the License.
jms-context
jms-shared-consumer
jmx
+ jmx-ssl
large-message
last-value-queue
management
@@ -135,6 +136,7 @@ under the License.
jms-context
jms-shared-consumer
jmx
+ jmx-ssl
large-message
last-value-queue
management