activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [11/48] activemq-artemis git commit: renaming broker-features -> features on examples
Date Thu, 13 Aug 2015 04:13:29 GMT
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/jmx/readme.html
----------------------------------------------------------------------
diff --git a/examples/features/standard/jmx/readme.html b/examples/features/standard/jmx/readme.html
new file mode 100644
index 0000000..8dd4fe9
--- /dev/null
+++ b/examples/features/standard/jmx/readme.html
@@ -0,0 +1,181 @@
+<!--
+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 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</b> from this directory, <br>or <b>mvn -PnoServer verify</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</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, the Java Virtual machine must be started with system properties:
+         <pre class="prettyprint">
+             <code>-Dcom.sun.management.jmxremote
+             -Dcom.sun.management.jmxremote.port=3000
+             -Dcom.sun.management.jmxremote.ssl=false
+             -Dcom.sun.management.jmxremote.authenticate=false</code>
+        </pre>
+        <p>These properties are explained in the Java 5 <a href="http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html#remote">Management guide</a>
+            (please note that for this example, we will disable user authentication for simplicity sake).</p>
+        <p>With these properties, ActiveMQ Artemis server will be manageable remotely using standard JMX URL on port <code>3000</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://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html#connecting">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://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html">Java 5 Management guide</a></li>
+     </ul>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/jmx/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..108897f
--- /dev/null
+++ b/examples/features/standard/jmx/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java
@@ -0,0 +1,121 @@
+/*
+ * 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 java.util.HashMap;
+
+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 org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
+import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
+
+/**
+ * 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:3000/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.getJMSQueueObjectName(queue.getQueueName());
+
+         // Step 10. Create JMX Connector to connect to the server's MBeanServer
+         JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMXExample.JMX_URL), new HashMap());
+
+         // Step 11. Retrieve the MBeanServerConnection
+         MBeanServerConnection mbsc = connector.getMBeanServerConnection();
+
+         // Step 12. Create a JMSQueueControl proxy to manage the queue on the server
+         JMSQueueControl queueControl = MBeanServerInvocationHandler.newProxyInstance(mbsc, on, JMSQueueControl.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(message.getJMSMessageID()));
+
+         // 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();
+         }
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/jmx/src/main/resources/activemq/server0/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/examples/features/standard/jmx/src/main/resources/activemq/server0/artemis-roles.properties b/examples/features/standard/jmx/src/main/resources/activemq/server0/artemis-roles.properties
new file mode 100644
index 0000000..4e2d44c
--- /dev/null
+++ b/examples/features/standard/jmx/src/main/resources/activemq/server0/artemis-roles.properties
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+guest=guest
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/jmx/src/main/resources/activemq/server0/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/features/standard/jmx/src/main/resources/activemq/server0/artemis-users.properties b/examples/features/standard/jmx/src/main/resources/activemq/server0/artemis-users.properties
new file mode 100644
index 0000000..4e2d44c
--- /dev/null
+++ b/examples/features/standard/jmx/src/main/resources/activemq/server0/artemis-users.properties
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+guest=guest
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/jmx/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/features/standard/jmx/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/jmx/src/main/resources/activemq/server0/broker.xml
new file mode 100644
index 0000000..7a30153
--- /dev/null
+++ b/examples/features/standard/jmx/src/main/resources/activemq/server0/broker.xml
@@ -0,0 +1,64 @@
+<?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.
+-->
+
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+               xmlns="urn:activemq"
+               xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
+
+   <jms xmlns="urn:activemq:jms">
+      <!--the queue used by the example-->
+      <queue name="exampleQueue"/>
+   </jms>
+
+   <core xmlns="urn:activemq:core">
+
+      <bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory>
+
+      <journal-directory>${data.dir}/server0/data/messaging/journal</journal-directory>
+
+      <large-messages-directory>${data.dir}/server0/data/messaging/largemessages</large-messages-directory>
+
+      <paging-directory>${data.dir}/server0/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="jms.queue.exampleQueue">
+            <permission type="createDurableQueue" roles="guest"/>
+            <permission type="deleteDurableQueue" roles="guest"/>
+            <permission type="createNonDurableQueue" roles="guest"/>
+            <permission type="deleteNonDurableQueue" roles="guest"/>
+            <permission type="consume" roles="guest"/>
+            <permission type="send" roles="guest"/>
+         </security-setting>
+      </security-settings>
+
+   </core>
+</configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/jmx/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/features/standard/jmx/src/main/resources/jndi.properties b/examples/features/standard/jmx/src/main/resources/jndi.properties
new file mode 100644
index 0000000..93537c4
--- /dev/null
+++ b/examples/features/standard/jmx/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

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/large-message/pom.xml
----------------------------------------------------------------------
diff --git a/examples/features/standard/large-message/pom.xml b/examples/features/standard/large-message/pom.xml
new file mode 100644
index 0000000..007ccd7
--- /dev/null
+++ b/examples/features/standard/large-message/pom.xml
@@ -0,0 +1,88 @@
+<?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>1.0.1-SNAPSHOT</version>
+   </parent>
+
+   <artifactId>large-message</artifactId>
+   <packaging>jar</packaging>
+   <name>ActiveMQ Artemis JMS Large Message Example</name>
+
+   <properties>
+      <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
+   </properties>
+
+   <dependencies>
+      <dependency>
+         <groupId>org.apache.activemq</groupId>
+         <artifactId>artemis-cli</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>
+               </execution>
+               <execution>
+                  <id>runClient</id>
+                  <goals>
+                     <goal>runClient</goal>
+                  </goals>
+                  <configuration>
+                     <clientClass>org.apache.activemq.artemis.jms.example.LargeMessageExample</clientClass>
+                     <args>
+                        <param>${basedir}/target/server0</param>
+                     </args>
+                  </configuration>
+               </execution>
+            </executions>
+            <dependencies>
+               <dependency>
+                  <groupId>org.apache.activemq.examples.broker</groupId>
+                  <artifactId>large-message</artifactId>
+                  <version>${project.version}</version>
+               </dependency>
+            </dependencies>
+         </plugin>
+      </plugins>
+   </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/large-message/readme.html
----------------------------------------------------------------------
diff --git a/examples/features/standard/large-message/readme.html b/examples/features/standard/large-message/readme.html
new file mode 100644
index 0000000..0dc42cb
--- /dev/null
+++ b/examples/features/standard/large-message/readme.html
@@ -0,0 +1,200 @@
+<!--
+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 Large Message 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>Large Message Example</h1>
+
+     <pre>To run the example, simply type <b>mvn verify</b> from this directory, This example will start and stop the server since it will look for a failure.</pre>
+
+
+     <p>This example shows you how to send and receive very large messages with ActiveMQ Artemis.</p>
+     <p>ActiveMQ Artemis supports the sending and receiving of huge messages, much larger than can fit in available RAM
+     on the client or server. Effectively the only limit to message size is the amount of disk space you have on the server.</p>
+     <p>Large messages are persisted on the server so they can survive a server restart. In other words ActiveMQ Artemis doesn't just
+     do a simple socket stream from the sender to the consumer.</p>
+     <p>In order to do this ActiveMQ Artemis provides an extension to JMS where you can use an InputStream or OutputStream as the source and destination for your messages. You can send messages as large as it would fit in your disk.</p>
+     <p>You may also choose to read LargeMessages using the regular ByteStream or ByteMessage methods, but using the InputStream and OutputStream will provide you a much better performance</p>
+
+     <h2>Example step-by-step</h2>
+     <p>In this example we limit both the server and the client to be running in a maximum of 50MB of RAM,
+     and we send a message with a body of size 256MB.</p>
+     <p>ActiveMQ Artemis can support much large message sizes but we
+     choose these sizes and limit RAM so the example runs more quickly.</p>
+     <p>We create a file on disk representing the message body, create
+     a FileInputStream on that file and set that InputStream as the body of the message before sending.</p>
+     <p>The message is sent, then we stop the server, and restart it. This demonstrates the large message will survive a restart of the server.</p>
+     <p>Once the server is restarted we receive the message and stream it's body to another file on disk.</p>
+
+     <ol>
+        <li>Create an initial context to perform the JNDI lookup.</li>
+        <pre class="prettyprint">
+           <code>initialContext = getContext(0);</code>
+        </pre>
+
+        <li>Perfom a lookup on the queue.</li>
+        <pre class="prettyprint">
+           <code>Queue queue = (Queue)initialContext.lookup("/queue/exampleQueue");</code>
+        </pre>
+
+        <li>Perform a lookup on the Connection Factory. This ConnectionFactory has a special attribute set on it. activemq-jms.xml)
+            Messages with more than 10K are considered large.</li>
+        <pre class="prettyprint">
+           <code>ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");</code>
+        </pre>
+
+        <li>Create the JMS objects for sending the message.</li>
+        <pre class="prettyprint">
+           <code>
+        connection = cf.createConnection();
+
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        MessageProducer producer = session.createProducer(queue);
+           </code>
+        </pre>
+
+        <li>Create a huge file - this will form the body of the message we will send.</li>
+        <pre class="prettyprint">
+           <code>
+        File fileInput = new File("huge_message_to_send.dat");
+
+        fileInput.createNewFile();
+
+        createFile(fileInput, FILE_SIZE);
+           </code>
+        </pre>
+
+        <li>Create a BytesMessage</li>
+        <pre class="prettyprint">
+          <code>BytesMessage message = session.createBytesMessage();</code>
+       </pre>
+
+        <li>We set the InputStream on the message. When sending the message will read the InputStream
+        until it gets EOF. In this case we point the InputStream at a file on disk, and it will suck up the entire
+        file, however we could use any InputStream not just a FileInputStream.</li>
+        <pre class="prettyprint"><code>
+         FileInputStream fileInputStream = new FileInputStream(fileInput);
+
+         BufferedInputStream bufferedInput = new BufferedInputStream(fileInputStream);
+
+         message.setObjectProperty("JMS_AMQ_InputStream", bufferedInput);
+        </code></pre>
+
+        <li>Send the Message.</li>
+        <pre class="prettyprint"><code>
+         producer.send(message);
+         </code></pre>
+
+
+        <li>We send message to the queue. After the send completion the message file will be located at ./build/data/largeMessages</li>
+        <pre class="prettyprint">
+           <code>messageProducer.send(message);</code>
+        </pre>
+
+        <li>
+        To demonstrate that that we're not simply streaming the message from sending to consumer, we stop
+        the server and restart it before consuming the message. This demonstrates that the large message gets persisted, like a
+        normal persistent message, on the server. If you look at ./build/data/largeMessages you will see the largeMessage
+        stored on disk the server.
+        </li>
+          <pre class="prettyprint">
+           <code>
+        connection.close();
+
+        initialContext.close();
+
+        stopServer(0);
+
+        // Give the server a little time to shutdown properly
+        Thread.sleep(5000);
+
+        startServer(0);
+           </code>
+        </pre>
+
+        <li>Now the server is restarted we can recreate the JMS Objects, and start the new connection.</li>
+        <pre class="prettyprint">
+           <code>
+        initialContext = getContext(0);
+
+        queue = (Queue)initialContext.lookup("/queue/exampleQueue");
+
+        cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
+
+        connection = cf.createConnection();
+
+        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        MessageConsumer messageConsumer = session.createConsumer(queue);
+
+        connection.start();
+
+           </code>
+        </pre>
+
+        <li>Receive the message. When we receive the large message we initially just receive the message with
+        an empty body.</li>
+        <pre class="prettyprint"><code>BytesMessage messageReceived = (BytesMessage)messageConsumer.receive(120000);
+        </code></pre>
+
+        <li>We set an OutputStream on the message. This causes the message body to be written to the
+         OutputStream until there are no more bytes to be written.
+         You don't have to use a FileOutputStream, you can use any OutputStream.
+         You may choose to use the regular BytesMessage or
+         StreamMessage interface but this method is much faster for large messages.</li>
+        <pre class="prettyprint"><code>
+         File outputFile = new File("huge_message_received.dat");
+
+         FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
+
+         BufferedOutputStream bufferedOutput = new BufferedOutputStream(fileOutputStream);
+
+        </code></pre>
+
+         <li>This will save the stream and wait until the entire message is written before continuing.</li>
+        <pre class="prettyprint"><code>
+         messageReceived.setObjectProperty("JMS_AMQ_SaveStream", bufferedOutput);
+        </code></pre>
+
+        <li>Be sure to close our resources!</li>
+
+        <pre class="prettyprint">
+           <code>
+           finally
+           {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
+              if (connection != null)
+              {
+                 connection.close();
+              }
+           }</code>
+        </pre>
+     </ol>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java
----------------------------------------------------------------------
diff --git a/examples/features/standard/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java b/examples/features/standard/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java
new file mode 100644
index 0000000..88ad6cc
--- /dev/null
+++ b/examples/features/standard/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java
@@ -0,0 +1,193 @@
+/*
+ * 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 org.apache.activemq.artemis.util.ServerUtil;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+/**
+ * This example demonstrates the ability of ActiveMQ Artemis to send and consume a very large message, much
+ * bigger than can fit in RAM.
+ */
+public class LargeMessageExample {
+
+   /**
+    * The message we will send is size 2GiB, even though we are only running in 50MB of RAM on both
+    * client and server.
+    * <p>
+    * This may take some considerable time to create, send and consume - if it takes too long or you
+    * don't have enough disk space just reduce the file size here
+    */
+   private static final long FILE_SIZE = 2L * 1024 * 1024 * 1024; // 2 GiB message
+
+   public static void main(final String[] args) throws Exception {
+      Process server = null;
+      Connection connection = null;
+      InitialContext initialContext = null;
+
+      try {
+         server = ServerUtil.startServer(args[0], LargeMessageExample.class.getSimpleName(), 0, 5000);
+
+         // 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. This ConnectionFactory has a special attribute set on
+         // it.
+         // Messages with more than 10K are considered large
+         ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory");
+
+         // Step 4. Create the JMS objects
+         connection = cf.createConnection();
+
+         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         MessageProducer producer = session.createProducer(queue);
+
+         // Step 5. Create a huge file - this will form the body of the message we will send.
+
+         System.out.println("Creating a file to send of size " + FILE_SIZE +
+                               " bytes. This may take a little while... " +
+                               "If this is too big for your disk you can easily change the FILE_SIZE in the example.");
+
+         File fileInput = new File("huge_message_to_send.dat");
+
+         createFile(fileInput, FILE_SIZE);
+
+         System.out.println("File created.");
+
+         // Step 6. Create a BytesMessage
+         BytesMessage message = session.createBytesMessage();
+
+         // Step 7. We set the InputStream on the message. When sending the message will read the InputStream
+         // until it gets EOF. In this case we point the InputStream at a file on disk, and it will suck up the entire
+         // file, however we could use any InputStream not just a FileInputStream.
+         FileInputStream fileInputStream = new FileInputStream(fileInput);
+         BufferedInputStream bufferedInput = new BufferedInputStream(fileInputStream);
+
+         message.setObjectProperty("JMS_AMQ_InputStream", bufferedInput);
+
+         System.out.println("Sending the huge message.");
+
+         // Step 9. Send the Message
+         producer.send(message);
+
+         System.out.println("Large Message sent");
+
+         System.out.println("Stopping server.");
+
+         // Step 10. To demonstrate that that we're not simply streaming the message from sending to consumer, we stop
+         // the server and restart it before consuming the message. This demonstrates that the large message gets
+         // persisted, like a
+         // normal persistent message, on the server. If you look at ./build/data/largeMessages you will see the
+         // largeMessage stored on disk the server
+
+         connection.close();
+
+         initialContext.close();
+
+         ServerUtil.killServer(server);
+
+         server = ServerUtil.startServer(args[0], "LargeMessageExample", 0, 5000);
+
+         System.out.println("Server restarted.");
+
+         // Step 11. Now the server is restarted we can recreate the JMS Objects, and start the new connection
+
+         initialContext = new InitialContext();
+
+         queue = (Queue) initialContext.lookup("queue/exampleQueue");
+
+         cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory");
+
+         connection = cf.createConnection();
+
+         session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         MessageConsumer messageConsumer = session.createConsumer(queue);
+
+         connection.start();
+
+         System.out.println("Receiving message.");
+
+         // Step 12. Receive the message. When we receive the large message we initially just receive the message with
+         // an empty body.
+         BytesMessage messageReceived = (BytesMessage) messageConsumer.receive(120000);
+
+         System.out.println("Received message with: " + messageReceived.getLongProperty("_AMQ_LARGE_SIZE") +
+                               " bytes. Now streaming to file on disk.");
+
+         // Step 13. We set an OutputStream on the message. This causes the message body to be written to the
+         // OutputStream until there are no more bytes to be written.
+         // You don't have to use a FileOutputStream, you can use any OutputStream.
+         // You may choose to use the regular BytesMessage or
+         // StreamMessage interface but this method is much faster for large messages.
+
+         File outputFile = new File("huge_message_received.dat");
+
+         FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
+
+         BufferedOutputStream bufferedOutput = new BufferedOutputStream(fileOutputStream);
+
+         // Step 14. This will save the stream and wait until the entire message is written before continuing.
+         messageReceived.setObjectProperty("JMS_AMQ_SaveStream", bufferedOutput);
+
+         fileOutputStream.close();
+
+         System.out.println("File streamed to disk. Size of received file on disk is " + outputFile.length());
+      }
+      finally {
+         // Step 12. Be sure to close our resources!
+         if (initialContext != null) {
+            initialContext.close();
+         }
+
+         if (connection != null) {
+            connection.close();
+         }
+
+         ServerUtil.killServer(server);
+      }
+   }
+
+   private static void createFile(final File file, final long fileSize) throws IOException {
+      FileOutputStream fileOut = new FileOutputStream(file);
+      BufferedOutputStream buffOut = new BufferedOutputStream(fileOut);
+      byte[] outBuffer = new byte[1024 * 1024];
+      for (long i = 0; i < fileSize; i += outBuffer.length) {
+         buffOut.write(outBuffer);
+      }
+      buffOut.close();
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/large-message/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/features/standard/large-message/src/main/resources/jndi.properties b/examples/features/standard/large-message/src/main/resources/jndi.properties
new file mode 100644
index 0000000..93537c4
--- /dev/null
+++ b/examples/features/standard/large-message/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

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/last-value-queue/pom.xml
----------------------------------------------------------------------
diff --git a/examples/features/standard/last-value-queue/pom.xml b/examples/features/standard/last-value-queue/pom.xml
new file mode 100644
index 0000000..e38c08e
--- /dev/null
+++ b/examples/features/standard/last-value-queue/pom.xml
@@ -0,0 +1,109 @@
+<?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>1.0.1-SNAPSHOT</version>
+   </parent>
+
+   <artifactId>last-value-queue</artifactId>
+   <packaging>jar</packaging>
+   <name>ActiveMQ Artemis JMS Last Value Queue Example</name>
+
+   <properties>
+      <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
+   </properties>
+
+   <dependencies>
+      <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>
+                  </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.LastValueQueueExample</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>last-value-queue</artifactId>
+                  <version>${project.version}</version>
+               </dependency>
+            </dependencies>
+         </plugin>
+      </plugins>
+   </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/last-value-queue/readme.html
----------------------------------------------------------------------
diff --git a/examples/features/standard/last-value-queue/readme.html b/examples/features/standard/last-value-queue/readme.html
new file mode 100644
index 0000000..1fb58ee
--- /dev/null
+++ b/examples/features/standard/last-value-queue/readme.html
@@ -0,0 +1,162 @@
+<!--
+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 Last-Value Queue 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>Last-Value Queue Example</h1>
+
+     <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre>
+
+     <p>This example shows you how to configure and use last-value queues.</p>
+     <p>Last-Value queues are special queues which discard any messages when a newer message with the same value for a well-defined <em>Last-Value</em> property is put in the queue.
+         In other words, a Last-Value queue only retains the last value.</p>
+     <p>A typical example for Last-Value queue is for stock prices, where you are only interested by the latest value for a particular stock.</p>
+
+     <p>The example will send 3 messages with the same <em>Last-Value</em> property to a to a Last-Value queue.<br />
+        We will browse the queue and see that only the last message is in the queue, the first two messages have been discarded. <br />
+        We will then consume from the queue the <em>last</em> message.</p>
+
+     <h2>Example setup</h2>
+     <p>Last-Value queues are defined in the configuration file <a href="server0/broker.xml">broker.xml</a>:</p>
+     <pre class="prettyprint">
+         <code>&lt;address-setting match="jms.queue.lastValueQueue"&gt;
+                &lt;last-value-queue&gt;true&lt;/last-value-queue&gt;
+         &lt;/address-setting&gt;</code>
+     </pre>
+
+     <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 it's properties from the <a href="server0/client-jndi.properties">client-jndi.properties</a></li>
+        <pre class="prettyprint">
+           <code>InitialContext initialContext = getContext();</code>
+        </pre>
+
+        <li>We look up the JMS queue object from JNDI</li>
+        <pre class="prettyprint">
+           <code>Queue queue = (Queue) initialContext.lookup("/queue/lastValueQueue");</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, a session and a producer for the queue</li>
+        <pre class="prettyprint">
+           <code> connection = cf.createConnection();
+            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            MessageProducer producer = session.createProducer(queue);</code>
+       </pre>
+
+       <li>We will create and send a text message with the Last-Value property set to <code>STOCK_NAME</code></li>
+       <pre class="prettyprint">
+           <code>TextMessage message = session.createTextMessage("1st message with Last-Value property set");
+           message.setStringProperty("_AMQ_LVQ_NAME", "STOCK_NAME");
+           producer.send(message);
+           System.out.format("Sent message: %s\n", message.getText());</code>
+       </pre>
+
+       <p><em>The <em>Last-Value</em> key is defined in ActiveMQ's MessageImpl class. Its value is <code>"_AMQ_LVQ_NAME"</code></em></p>
+
+       <li>We will create and send a <em>second</em> text message with the Last-Value property set to <code>STOCK_NAME</code></li>
+       <pre class="prettyprint">
+           <code>message = session.createTextMessage("2nd message with Last-Value property set");
+           message.setStringProperty("_AMQ_LVQ_NAME", "STOCK_NAME");
+           producer.send(message);
+           System.out.format("Sent message: %s\n", message.getText());</code>
+       </pre>
+
+       <li>We will create and send a <em>third</em> text message with the Last-Value property set to <code>STOCK_NAME</code></li>
+       <pre class="prettyprint">
+           <code>message = session.createTextMessage("3rd message with Last-Value property set");
+           message.setStringProperty("_AMQ_LVQ_NAME", "STOCK_NAME");
+           producer.send(message);
+           System.out.format("Sent message: %s\n", message.getText());</code>
+       </pre>
+
+       <p><em>When the 2<sup>nd</sup> message was sent to the queue, the 1<sup>st</sup> message was discarded.<br />
+           Similarly, when the 3<sup>rd</sup> message was sent to the queue, the 2<sup>nd</sup> message was discarded.<br />
+           Only the 3<sup>rd</sup> message remains in the queue.</em></p>
+
+        <li>We will browse the queue. There will be a single message displayed: the 3<sup>rd</sup> message</li>
+        <pre class="prettyprint">
+            <code>QueueBrowser browser = session.createBrowser(queue);
+            Enumeration enumeration = browser.getEnumeration();
+            while (enumeration.hasMoreElements())
+            {
+               TextMessage messageInTheQueue = (TextMessage)enumeration.nextElement();
+               System.out.format("Message in the queue: %s\n", messageInTheQueue.getText());
+            }
+            browser.close();
+            </code>
+        </pre>
+
+        <p><em>We will now consume the message on the queue</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. It will be the 3<sup>rd</sup> message</li>
+        <pre class="prettyprint">
+           <code> TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000);
+            System.out.format("Received message: %s\n", messageReceived.getText());</code>
+        </pre>
+
+        <li>We will try to receive another message but there is no other on the queue. The <code>receive</code> method will timeout after 5 seconds</li>
+        <pre class="prettyprint">
+           <code> messageReceived = (TextMessage)messageConsumer.receive(5000);
+           System.out.format("Received message: %s\n", 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#last-value-queues">Last-Value Queues chapter</a></li>
+     </ul>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/last-value-queue/src/main/java/org/apache/activemq/artemis/jms/example/LastValueQueueExample.java
----------------------------------------------------------------------
diff --git a/examples/features/standard/last-value-queue/src/main/java/org/apache/activemq/artemis/jms/example/LastValueQueueExample.java b/examples/features/standard/last-value-queue/src/main/java/org/apache/activemq/artemis/jms/example/LastValueQueueExample.java
new file mode 100644
index 0000000..469f839
--- /dev/null
+++ b/examples/features/standard/last-value-queue/src/main/java/org/apache/activemq/artemis/jms/example/LastValueQueueExample.java
@@ -0,0 +1,104 @@
+/*
+ * 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.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.QueueBrowser;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import java.util.Enumeration;
+
+import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+
+/**
+ * This example shows how to configure and use a <em>Last-Value</em> queues.
+ * Only the last message with a well-defined property is hold by the queue.
+ */
+public class LastValueQueueExample {
+
+   public static void main(final String[] args) throws Exception {
+      Connection connection = null;
+      try {
+         // Step 2. new Queue
+         Queue queue = ActiveMQJMSClient.createQueue("exampleQueue");
+
+         // Step 3. new Connection Factory
+         ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory();
+
+         // Step 4.Create a JMS Connection, session and producer on the queue
+         connection = cf.createConnection();
+         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         MessageProducer producer = session.createProducer(queue);
+
+         // Step 5. Create and send a text message with the Last-Value header set
+         TextMessage message = session.createTextMessage("1st message with Last-Value property set");
+         message.setStringProperty("_AMQ_LVQ_NAME", "STOCK_NAME");
+         producer.send(message);
+         System.out.format("Sent message: %s%n", message.getText());
+
+         // Step 6. Create and send a second text message with the Last-Value header set
+         message = session.createTextMessage("2nd message with Last-Value property set");
+         message.setStringProperty("_AMQ_LVQ_NAME", "STOCK_NAME");
+         producer.send(message);
+         System.out.format("Sent message: %s%n", message.getText());
+
+         // Step 7. Create and send a third text message with the Last-Value header set
+         message = session.createTextMessage("3rd message with Last-Value property set");
+         message.setStringProperty("_AMQ_LVQ_NAME", "STOCK_NAME");
+         producer.send(message);
+         System.out.format("Sent message: %s%n", message.getText());
+
+         // Step 8. Browse the queue. There is only 1 message in it, the last sent
+         QueueBrowser browser = session.createBrowser(queue);
+         Enumeration enumeration = browser.getEnumeration();
+         while (enumeration.hasMoreElements()) {
+            TextMessage messageInTheQueue = (TextMessage) enumeration.nextElement();
+            System.out.format("Message in the queue: %s%n", messageInTheQueue.getText());
+         }
+         browser.close();
+
+         // Step 9. Create a JMS Message Consumer for the queue
+         MessageConsumer messageConsumer = session.createConsumer(queue);
+
+         // Step 10. Start the Connection
+         connection.start();
+
+         // Step 11. Trying to receive a message. Since the queue is configured to keep only the
+         // last message with the Last-Value header set, the message received is the last sent
+         TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
+         System.out.format("Received message: %s%n", messageReceived.getText());
+
+         // Step 12. Trying to receive another message but there will be none.
+         // The 1st message was discarded when the 2nd was sent to the queue.
+         // The 2nd message was in turn discarded when the 3trd was sent to the queue
+         messageReceived = (TextMessage) messageConsumer.receive(5000);
+         System.out.format("Received message: %s%n", messageReceived);
+
+         cf.close();
+      }
+      finally {
+         // Step 13. Be sure to close our JMS resources!
+         if (connection != null) {
+            connection.close();
+         }
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/last-value-queue/src/main/resources/activemq/server0/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/examples/features/standard/last-value-queue/src/main/resources/activemq/server0/artemis-roles.properties b/examples/features/standard/last-value-queue/src/main/resources/activemq/server0/artemis-roles.properties
new file mode 100644
index 0000000..4e2d44c
--- /dev/null
+++ b/examples/features/standard/last-value-queue/src/main/resources/activemq/server0/artemis-roles.properties
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+guest=guest
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/last-value-queue/src/main/resources/activemq/server0/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/features/standard/last-value-queue/src/main/resources/activemq/server0/artemis-users.properties b/examples/features/standard/last-value-queue/src/main/resources/activemq/server0/artemis-users.properties
new file mode 100644
index 0000000..4e2d44c
--- /dev/null
+++ b/examples/features/standard/last-value-queue/src/main/resources/activemq/server0/artemis-users.properties
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+guest=guest
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/last-value-queue/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/features/standard/last-value-queue/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/last-value-queue/src/main/resources/activemq/server0/broker.xml
new file mode 100644
index 0000000..470de98
--- /dev/null
+++ b/examples/features/standard/last-value-queue/src/main/resources/activemq/server0/broker.xml
@@ -0,0 +1,67 @@
+<?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.
+-->
+
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+               xmlns="urn:activemq"
+               xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
+
+   <jms xmlns="urn:activemq:jms">
+      <!--the queue used by the example-->
+      <queue name="exampleQueue"/>
+   </jms>
+
+   <core xmlns="urn:activemq:core">
+
+      <bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory>
+
+      <journal-directory>${data.dir}/server0/data/messaging/journal</journal-directory>
+
+      <large-messages-directory>${data.dir}/server0/data/messaging/largemessages</large-messages-directory>
+
+      <paging-directory>${data.dir}/server0/data/messaging/paging</paging-directory>
+
+      <!-- Acceptors -->
+      <acceptors>
+         <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor>
+      </acceptors>
+
+      <!-- Other config -->
+
+      <security-settings>
+         <!--security for example queue-->
+         <security-setting match="jms.queue.exampleQueue">
+            <permission type="createDurableQueue" roles="guest"/>
+            <permission type="deleteDurableQueue" roles="guest"/>
+            <permission type="createNonDurableQueue" roles="guest"/>
+            <permission type="deleteNonDurableQueue" roles="guest"/>
+            <permission type="consume" roles="guest"/>
+            <permission type="send" roles="guest"/>
+         </security-setting>
+      </security-settings>
+
+      <address-settings>
+         <!--override the expiry address for the example-->
+         <address-setting match="jms.queue.lastValueQueue">
+            <last-value-queue>true</last-value-queue>
+         </address-setting>
+      </address-settings>
+
+   </core>
+</configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/last-value-queue/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/features/standard/last-value-queue/src/main/resources/jndi.properties b/examples/features/standard/last-value-queue/src/main/resources/jndi.properties
new file mode 100644
index 0000000..93537c4
--- /dev/null
+++ b/examples/features/standard/last-value-queue/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

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/management-notifications/pom.xml
----------------------------------------------------------------------
diff --git a/examples/features/standard/management-notifications/pom.xml b/examples/features/standard/management-notifications/pom.xml
new file mode 100644
index 0000000..bade921
--- /dev/null
+++ b/examples/features/standard/management-notifications/pom.xml
@@ -0,0 +1,109 @@
+<?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>1.0.1-SNAPSHOT</version>
+   </parent>
+
+   <artifactId>management-notifications</artifactId>
+   <packaging>jar</packaging>
+   <name>ActiveMQ Artemis JMS Management Notifications Example</name>
+
+   <properties>
+      <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
+   </properties>
+
+   <dependencies>
+      <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>
+                  </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.ManagementNotificationExample</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>management-notifications</artifactId>
+                  <version>${project.version}</version>
+               </dependency>
+            </dependencies>
+         </plugin>
+      </plugins>
+   </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/features/standard/management-notifications/readme.html
----------------------------------------------------------------------
diff --git a/examples/features/standard/management-notifications/readme.html b/examples/features/standard/management-notifications/readme.html
new file mode 100644
index 0000000..6ac1efa
--- /dev/null
+++ b/examples/features/standard/management-notifications/readme.html
@@ -0,0 +1,215 @@
+<!--
+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 Management Notification 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>Management Notification Example</h1>
+
+     <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre>
+
+     <p>This example shows how to receive management notifications from ActiveMQ Artemis using JMS Messages.</p>
+     <p>ActiveMQ Artemis servers emit management notifications when events of interest occur (consumers are created or closed,
+         destinations are created or deleted, security authentication fails, etc.).<br />
+         These notifications can be received either by using JMX (see <a href="../jmx/readme.html">JMX example</a>) or by receiving JMS Messages
+         from a well-known destination.</p>
+     <p>This example will setup a JMS MessageListener to receive management notifications. We will also perform normal JMS operations to see the kind
+         of notifications they trigger.</p>
+
+     <h2>Example configuration</h2>
+
+     <p>ActiveMQ Artemis can configured to send JMS messages when management notifications are emitted on the server.</p>
+     <p>By default, the management name is called <code>activemq.notifications</code> but this can be configured in <a href="server0/broker.xml">broker.xml</a>.
+        For this example, we will set it to <code>jms.topic.notificationsTopic</code> to be able to receive notifications from a JMS Topic.</p>
+      <pre class="prettyprint">
+         <code>&lt;management-notification-address&gt;jms.topic.notificationsTopic&lt;/management-notification-address&gt;</code>
+     </pre>
+
+     <p>Since we want to lookup the notifications topic using JNDI, we also declare it in  <a href="server0/activemq-jms.xml">activemq-jms.xml</a>
+     <pre class="prettyprint">
+         <code>&lt;topic name="notificationsTopic"&gt;
+            &lt;entry name="/topic/notificationsTopic"/&gt;
+         &lt;/topic&gt;</code>
+     </pre>
+     <p>The notification queue requires permission to create/delete temporary queues and consume messages.
+         This is also configured in <a href="server0/broker.xml">broker.xml</a></p>
+     <pre class="prettyprint">
+         <code><!--security for notification topic-->
+         &lt;security-setting match="jms.topic.notificationsTopic"&gt;
+            &lt;permission type="consume" roles="guest"/&gt;
+            &lt;permission type="createNonDurableQueue" roles="guest"/&gt;
+            &lt;permission type="deleteNonDurableQueue" roles="guest"/&gt;
+         &lt;/security-setting&gt;</code>
+     </pre>
+
+     <h2>Example step-by-step</h2>
+x     <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, a session and a message producer for the example queue</li>
+        <pre class="prettyprint">
+            <code>connection = cf.createConnection();
+            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            MessageProducer producer = session.createProducer(queue);</code>
+        </pre>
+
+        <li>We look up the JMS Topic used to receive the notifications from JNDI</li>
+        <pre class="prettyprint">
+            <code>Topic notificationsTopic = (Topic) initialContext.lookup("/topic/notificationsTopic");</code>
+        </pre>
+
+        <li>We create a MessageConsumer for the notification queue and set its MessageListener. When a notification is received, we will simply display all the message properties</li>
+        <pre class="prettyprint">
+           <code>MessageConsumer notificationConsumer = session.createConsumer(notificationsTopic);
+           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("------------------------");
+              }
+           });</code>
+        </pre>
+
+        <li>We start the connection to receive messages</li>
+        <pre class="prettyprint">
+            <code>connection.start();</code>
+        </pre>
+
+        <p><em>Now that a message listener is setup to receive management notifications, we will perform regular JMS operations to
+            see what kind of notifications are triggered</em></p>
+
+        <li>We create a JMS message consumer on the example queue</li>
+        <pre class="prettyprint">
+            <code>MessageConsumer consumer = session.createConsumer(queue);</code>
+        </pre>
+
+        <p>This will generate a <code>CONSUMER_CREATED</code> notification:
+        <pre class="prettyprint">
+            <code>------------------------
+            Received notification:
+              _AMQ_RoutingName: jms.queue.exampleQueue
+              _AMQ_Address: jms.queue.exampleQueue
+              ...
+              _AMQ_ConsumerCount: 1
+              ...
+              _AMQ_NotifType: CONSUMER_CREATED
+            ------------------------</code>
+        </pre>
+        <p>The notification tells us that a consumer was created for the JMS queue <code>exampleQueue</code>. When the notification
+            was emitted, this consumer was the only one for the queue</p>
+
+        <li>We close this consumer</li>
+        <pre class="prettyprint">
+            <code>consumer.close();</code>
+        </pre>
+
+        <p>This will generate a <code>CONSUMER_CLOSED</code> notification:
+        <pre class="prettyprint">
+            <code>------------------------
+            Received notification:
+              _AMQ_RoutingName: jms.queue.exampleQueue
+              _AMQ_Address: jms.queue.exampleQueue
+              ...
+              _AMQ_ConsumerCount: 0
+              ...
+              _AMQ_NotifType: CONSUMER_CLOSED
+            ------------------------</code>
+        </pre>
+        <p>The notification tells us that a consumer was closed for the JMS queue <code>exampleQueue</code>. When the notification
+            was emitted, there were no other consumers on the queue</p>
+
+        <li>As a last example, we will create a connection with invalid user credentials</li>
+        <pre class="prettyprint">
+            <code>try
+            {
+               cf.createConnection("not.a.valid.user", "not.a.valid.password");
+            } catch (JMSException e)
+            {
+            }</code>
+        </pre>
+
+        <p>This will generate a <code>SECURITY_AUTHENTICATION_VIOLATION</code> notification:
+        <pre class="prettyprint">
+            <code>------------------------
+            Received notification:
+              _AMQ_User: not.a.valid.user
+              ...
+              _AMQ_NotifType: SECURITY_AUTHENTICATION_VIOLATION
+            ------------------------
+            </code>
+        </pre>
+        <p>The notification tells us that a user named <code>not.a.valid.user</code> failed to authenticate when creating a connection to ActiveMQ Artemis.</p>
+
+        <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.notifications">Management Notifications chapter</a></li>
+     </ul>
+
+  </body>
+</html>


Mime
View raw message