activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbert...@apache.org
Subject [02/51] [partial] activemq-6 git commit: ACTIVEMQ6-1 - Initial HornetQ Donation Commit
Date Mon, 10 Nov 2014 16:32:13 GMT
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-durable-subscription/src/main/resources/hornetq/server1/hornetq-users.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-durable-subscription/src/main/resources/hornetq/server1/hornetq-users.xml b/examples/jms/clustered-durable-subscription/src/main/resources/hornetq/server1/hornetq-users.xml
new file mode 100644
index 0000000..934306c
--- /dev/null
+++ b/examples/jms/clustered-durable-subscription/src/main/resources/hornetq/server1/hornetq-users.xml
@@ -0,0 +1,7 @@
+<configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd">
+   <!-- the default user.  this is used where username is null-->
+   <defaultuser name="guest" password="guest">
+      <role name="guest"/>
+   </defaultuser>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-grouping/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/pom.xml b/examples/jms/clustered-grouping/pom.xml
new file mode 100644
index 0000000..7e1f38e
--- /dev/null
+++ b/examples/jms/clustered-grouping/pom.xml
@@ -0,0 +1,199 @@
+<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.hornetq.examples.jms</groupId>
+      <artifactId>jms-examples</artifactId>
+      <version>2.5.0-SNAPSHOT</version>
+   </parent>
+
+   <artifactId>hornetq-jms-clustered-grouping-example</artifactId>
+   <packaging>jar</packaging>
+   <name>HornetQ JMS CLustered Grouping Example</name>
+
+   <dependencies>
+      <dependency>
+         <groupId>org.hornetq.examples.jms</groupId>
+         <artifactId>hornetq-jms-examples-common</artifactId>
+         <version>${project.version}</version>
+      </dependency>
+      <dependency>
+         <groupId>org.jboss.spec.javax.jms</groupId>
+         <artifactId>jboss-jms-api_2.0_spec</artifactId>
+      </dependency>
+   </dependencies>
+
+   <build>
+      <plugins>
+         <plugin>
+            <groupId>org.hornetq</groupId>
+            <artifactId>hornetq-maven-plugin</artifactId>
+            <executions>
+               <execution>
+                  <id>start0</id>
+                  <goals>
+                     <goal>start</goal>
+                  </goals>
+                  <configuration>
+                     <hornetqConfigurationDir>${basedir}/target/classes/hornetq/server0</hornetqConfigurationDir>
+                     <systemProperties>
+                        <property>
+                           <name>build.directory</name>
+                           <value>${basedir}/target/</value>
+                        </property>
+                        <property>
+                           <name>udp-address</name>
+                           <value>${udp-address}</value>
+                        </property>
+                     </systemProperties>
+                  </configuration>
+               </execution>
+               <execution>
+                  <id>start1</id>
+                  <goals>
+                     <goal>start</goal>
+                  </goals>
+                  <configuration>
+                     <jndiPort>1199</jndiPort>
+                     <jndiRmiPort>1198</jndiRmiPort>
+                     <hornetqConfigurationDir>${basedir}/target/classes/hornetq/server1</hornetqConfigurationDir>
+                     <fork>true</fork>
+                     <systemProperties>
+                        <property>
+                           <name>build.directory</name>
+                           <value>${basedir}/target/</value>
+                        </property>
+                        <property>
+                           <name>udp-address</name>
+                           <value>${udp-address}</value>
+                        </property>
+                     </systemProperties>
+                  </configuration>
+               </execution>
+               <execution>
+                  <id>start2</id>
+                  <goals>
+                     <goal>start</goal>
+                  </goals>
+                  <configuration>
+                     <jndiPort>1299</jndiPort>
+                     <jndiRmiPort>1298</jndiRmiPort>
+                     <hornetqConfigurationDir>${basedir}/target/classes/hornetq/server2</hornetqConfigurationDir>
+                     <fork>true</fork>
+                     <systemProperties>
+                        <property>
+                           <name>build.directory</name>
+                           <value>${basedir}/target/</value>
+                        </property>
+                        <property>
+                           <name>udp-address</name>
+                           <value>${udp-address}</value>
+                        </property>
+                     </systemProperties>
+                  </configuration>
+               </execution>
+               <execution>
+                  <id>runClient</id>
+                  <goals>
+                     <goal>runClient</goal>
+                  </goals>
+                  <configuration>
+                     <clientClass>org.hornetq.jms.example.ClusteredGroupingExample</clientClass>
+                     <args>
+                        <param>jnp://localhost:1099</param>
+                        <param>jnp://localhost:1199</param>
+                        <param>jnp://localhost:1299</param>
+                     </args>
+                     <systemProperties>
+                        <property>
+                           <name>exampleConfigDir</name>
+                           <value>${basedir}/target/classes/hornetq</value>
+                        </property>
+                     </systemProperties>
+                  </configuration>
+               </execution>
+               <execution>
+                  <id>stop0</id>
+                  <goals>
+                     <goal>stop</goal>
+                  </goals>
+                  <configuration>
+                     <hornetqConfigurationDir>${basedir}/target/classes/hornetq/server0</hornetqConfigurationDir>
+                  </configuration>
+               </execution>
+               <execution>
+                  <id>stop1</id>
+                  <goals>
+                     <goal>stop</goal>
+                  </goals>
+                  <configuration>
+                     <hornetqConfigurationDir>${basedir}/target/classes/hornetq/server1</hornetqConfigurationDir>
+                  </configuration>
+               </execution>
+               <execution>
+                  <id>stop2</id>
+                  <goals>
+                     <goal>stop</goal>
+                  </goals>
+                  <configuration>
+                     <hornetqConfigurationDir>${basedir}/target/classes/hornetq/server2</hornetqConfigurationDir>
+                  </configuration>
+               </execution>
+            </executions>
+            <dependencies>
+               <dependency>
+                  <groupId>org.hornetq.examples.jms</groupId>
+                  <artifactId>hornetq-jms-clustered-grouping-example</artifactId>
+                  <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                  <groupId>org.hornetq</groupId>
+                  <artifactId>hornetq-core-client</artifactId>
+                  <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                  <groupId>org.hornetq</groupId>
+                  <artifactId>hornetq-server</artifactId>
+                  <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                  <groupId>org.hornetq</groupId>
+                  <artifactId>hornetq-jms-client</artifactId>
+                  <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                  <groupId>org.hornetq</groupId>
+                  <artifactId>hornetq-jms-server</artifactId>
+                  <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                  <groupId>io.netty</groupId>
+                  <artifactId>netty-all</artifactId>
+                  <version>${netty.version}</version>
+               </dependency>
+               <dependency>
+                  <groupId>org.jboss.javaee</groupId>
+                  <artifactId>jboss-jms-api</artifactId>
+                  <version>1.1.0.GA</version>
+               </dependency>
+               <dependency>
+                  <groupId>org.jboss.naming</groupId>
+                  <artifactId>jnpserver</artifactId>
+                  <version>5.0.3.GA</version>
+               </dependency>
+            </dependencies>
+            <configuration>
+               <waitOnStart>false</waitOnStart>
+               <systemProperties>
+                  <property>
+                     <name>build.directory</name>
+                     <value>${basedir}/target/</value>
+                  </property>
+               </systemProperties>
+            </configuration>
+         </plugin>
+      </plugins>
+   </build>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-grouping/readme.html
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/readme.html b/examples/jms/clustered-grouping/readme.html
new file mode 100644
index 0000000..f8ebf87
--- /dev/null
+++ b/examples/jms/clustered-grouping/readme.html
@@ -0,0 +1,246 @@
+<html>
+  <head>
+    <title>HornetQ JMS Clustered Grouping Example</title>
+    <link rel="stylesheet" type="text/css" href="../common/common.css">
+  </head>
+  <body>
+     <h1>JMS Clustered Grouping Example</h1>
+
+     <p>This example demonstrates how to ensure strict ordering across a cluster using clustered message grouping</p>
+     <p>We create 3 nodes each with a grouping message handler, one with a Local handler and 2 with a Remote handler.</p>
+     <p>The local handler acts as an arbitrator for the 2 remote handlers, holding the information on routes and communicating
+         the routing info with the remote handlers on the other 2 nodes</p>
+     <p>We then send some messages to each node with the same group id set and ensure the same consumer receives all of them</p>
+     <p>Here's the relevant snippet from the server configuration that has the local handler</p>
+     <pre>
+     <code>
+       &lt;cluster-connections&gt;
+          &lt;cluster-connection name="my-cluster"&gt;
+             &lt;address&gt;jms&lt;/address&gt;
+             &lt;connector-ref>netty-connector&lt;/connector-ref>
+             &lt;retry-interval&gt;500&lt;/retry-interval&gt;
+             &lt;use-duplicate-detection&gt;true&lt;/use-duplicate-detection&gt;
+             &lt;forward-when-no-consumers&gt;true&lt;/forward-when-no-consumers&gt;
+             &lt;max-hops&gt;1&lt;/max-hops&gt;
+             &lt;discovery-group-ref discovery-group-name="my-discovery-group"/&gt;
+          &lt;/cluster-connection&gt;
+       &lt;/cluster-connections&gt;
+
+       &lt;grouping-handler name="my-grouping-handler"&gt;
+          &lt;type&gt;LOCAL&lt;/type&gt;
+          &lt;address&gt;jms&lt;/address&gt;
+          &lt;timeout&gt;5000&lt;/timeout&gt;
+       &lt;/grouping-handler&gt;
+     </code>
+     </pre>
+
+     <p>Here's the relevant snippet from the server configuration that has the remote handlers</p>
+     <pre>
+     <code>
+       &lt;cluster-connections&gt;
+          &lt;cluster-connection name="my-cluster"&gt;
+             &lt;address&gt;jms&lt;/address&gt;
+             &lt;retry-interval&gt;500&lt;/retry-interval&gt;
+             &lt;use-duplicate-detection&gt;true&lt;/use-duplicate-detection&gt;
+             &lt;forward-when-no-consumers&gt;true&lt;/forward-when-no-consumers&gt;
+             &lt;max-hops&gt;1&lt;/max-hops&gt;
+             &lt;discovery-group-ref discovery-group-name="my-discovery-group"/&gt;
+          &lt;/cluster-connection&gt;
+       &lt;/cluster-connections&gt;
+
+       &lt;grouping-handler name="my-grouping-handler"&gt;
+          &lt;type&gt;REMOTE&lt;/type&gt;
+          &lt;address&gt;jms&lt;/address&gt;
+          &lt;timeout&gt;5000&lt;/timeout&gt;
+       &lt;/grouping-handler&gt;
+     </code>
+     </pre>
+     
+     <p>For more information on HornetQ clustering and grouping see the clustering and grouping
+     section of the user manual.</p>      
+     <h2>Example step-by-step</h2>
+     <p><i>To run the example, simply type <code>mvn verify</code> from this directory</i></p>
+
+      <ol>
+        <li> Get an initial context for looking up JNDI from server 0.</li>
+        <pre class="prettyprint">
+           <code>ic0 = getContext(0);</code>
+        </pre>
+
+        <li>Look-up the JMS Queue object from JNDI</li>
+        <pre class="prettyprint">
+           <code>Queue queue = (Queue)ic0.lookup("/queue/exampleQueue");</code>
+        </pre>
+
+        <li>Look-up a JMS Connection Factory object from JNDI on server 0</li>
+        <pre class="prettyprint">
+           <code>ConnectionFactory cf0 = (ConnectionFactory)ic0.lookup("/ConnectionFactory");</code>
+        </pre>
+
+        <li>Get an initial context for looking up JNDI from server 1.</li>
+        <pre class="prettyprint">
+           <code>ic1 = getContext(1);</code>
+        </pre>
+
+        <li>Look-up a JMS Connection Factory object from JNDI on server 1</li>
+        <pre class="prettyprint">
+           <code>ConnectionFactory cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
+           </code>
+        </pre>
+
+         <li>Get an initial context for looking up JNDI from server 2.</li>
+        <pre class="prettyprint">
+           <code>ic2 = getContext(2);</code>
+        </pre>
+
+        <li>Look-up a JMS Connection Factory object from JNDI on server 2</li>
+        <pre class="prettyprint">
+           <code>ConnectionFactory cf2 = (ConnectionFactory)ic2.lookup("/ConnectionFactory");
+           </code>
+        </pre>
+
+        <li>We create a JMS Connection connection0 which is a connection to server 0</li>
+        <pre class="prettyprint">
+           <code>connection0 = cf0.createConnection();</code>
+        </pre>
+
+         <li>We create a JMS Connection connection0 which is a connection to server 1</li>
+        <pre class="prettyprint">
+           <code>connection1 = cf1.createConnection();</code>
+        </pre>
+
+         <li>We create a JMS Connection connection0 which is a connection to server 2</li>
+        <pre class="prettyprint">
+           <code>connection2 = cf2.createConnection();</code>
+        </pre>
+
+         <li>We create a JMS Session on server 0</li>
+        <pre class="prettyprint">
+           <code>Session session0 = connection0.createSession(false, Session.AUTO_ACKNOWLEDGE);</code>
+        </pre>
+
+         <li>We create a JMS Session on server 1</li>
+        <pre class="prettyprint">
+           <code>Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);</code>
+        </pre>
+
+         <li>We create a JMS Session on server 2</li>
+        <pre class="prettyprint">
+           <code>Session session2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);</code>
+        </pre>
+
+         <li>We start the connections to ensure delivery occurs on them</li>
+        <pre class="prettyprint">
+           <code>
+         connection0.start();
+
+         connection1.start();
+
+         connection2.start();</code>
+        </pre>
+
+         <li>We create JMS MessageConsumer objects on server 0</li>
+        <pre class="prettyprint">
+           <code>MessageConsumer consumer = session0.createConsumer(queue);</code>
+        </pre>
+
+         <li>We create a JMS MessageProducer object on server 0, 1 and 2</li>
+        <pre class="prettyprint">
+           <code>
+         MessageProducer producer0 = session0.createProducer(queue);
+
+         MessageProducer producer1 = session1.createProducer(queue);
+
+         MessageProducer producer2 = session2.createProducer(queue);</code>
+        </pre>
+
+         <li>We send some messages to server 0, 1 and 2 with the same groupid set</li>
+        <pre class="prettyprint">
+           <code>
+         final int numMessages = 10;
+
+         for (int i = 0; i < numMessages; i++)
+         {
+            TextMessage message = session0.createTextMessage("This is text message " + i);
+
+            message.setStringProperty(HornetQMessage.JMSXGROUPID, "Group-0");
+
+            producer0.send(message);
+
+            System.out.println("Sent messages: " + message.getText() + " to node 0");
+         }
+
+         for (int i = 0; i < numMessages; i++)
+         {
+            TextMessage message = session1.createTextMessage("This is text message " + (i + 10));
+
+            message.setStringProperty(HornetQMessage.JMSXGROUPID, "Group-0");
+
+            producer1.send(message);
+
+            System.out.println("Sent messages: " + message.getText() + " to node 1");
+
+         }
+
+         for (int i = 0; i < numMessages; i++)
+         {
+            TextMessage message = session2.createTextMessage("This is text message " + (i + 20));
+
+            message.setStringProperty(HornetQMessage.JMSXGROUPID, "Group-0");
+
+            producer2.send(message);
+
+            System.out.println("Sent messages: " + message.getText() + " to node 2");
+         }
+        </code>
+        </pre>
+
+         <li>We now consume those messages from server 0. We note the messages have all been sent to the same consumer on the same node</li>
+        <pre class="prettyprint">
+           <code>
+         for (int i = 0; i < numMessages * 3; i++)
+         {
+            TextMessage message0 = (TextMessage)consumer.receive(5000);
+
+            System.out.println("Got message: " + message0.getText() + " from node 0");
+
+         }
+        </code>
+        </pre>
+         <li>Finally, Be sure to close our resources!</li>
+        <pre class="prettyprint">
+           <code>
+         if (connection0 != null)
+         {
+            connection0.close();
+         }
+
+         if (connection1 != null)
+         {
+            connection1.close();
+         }
+
+         if (connection2 != null)
+         {
+            connection2.close();
+         }
+
+         if (ic0 != null)
+         {
+            ic0.close();
+         }
+
+         if (ic1 != null)
+         {
+            ic1.close();
+         }
+
+         if (ic2 != null)
+         {
+            ic2.close();
+         }</code>
+        </pre>
+
+     </ol>
+  </body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-grouping/src/main/java/org/hornetq/jms/example/ClusteredGroupingExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/src/main/java/org/hornetq/jms/example/ClusteredGroupingExample.java b/examples/jms/clustered-grouping/src/main/java/org/hornetq/jms/example/ClusteredGroupingExample.java
new file mode 100644
index 0000000..6901227
--- /dev/null
+++ b/examples/jms/clustered-grouping/src/main/java/org/hornetq/jms/example/ClusteredGroupingExample.java
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat 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.hornetq.jms.example;
+
+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.jms.TextMessage;
+import javax.naming.InitialContext;
+
+import org.hornetq.common.example.HornetQExample;
+
+/**
+ * A simple example that demonstrates server side load-balancing of messages between the queue instances on different
+ * nodes of the cluster.
+ *
+ * @author <a href="tim.fox@jboss.com>Tim Fox</a>
+ */
+public class ClusteredGroupingExample extends HornetQExample
+{
+   public static void main(String[] args)
+   {
+      new ClusteredGroupingExample().run(args);
+   }
+
+   @Override
+   public boolean runExample() throws Exception
+   {
+      Connection connection0 = null;
+
+      Connection connection1 = null;
+
+      Connection connection2 = null;
+
+      InitialContext ic0 = null;
+
+      InitialContext ic1 = null;
+
+      InitialContext ic2 = null;
+
+      try
+      {
+         // Step 1. Get an initial context for looking up JNDI from server 0
+         ic0 = getContext(0);
+
+         // Step 2. Look-up the JMS Queue object from JNDI
+         Queue queue = (Queue)ic0.lookup("/queue/exampleQueue");
+
+         // Step 3. Look-up a JMS Connection Factory object from JNDI on server 0
+         ConnectionFactory cf0 = (ConnectionFactory)ic0.lookup("/ConnectionFactory");
+
+         // Step 4. Get an initial context for looking up JNDI from server 1
+         ic1 = getContext(1);
+
+         // Step 5. Look-up a JMS Connection Factory object from JNDI on server 1
+         ConnectionFactory cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
+
+         // Step 4. Get an initial context for looking up JNDI from server 1
+         ic2 = getContext(2);
+
+         // Step 5. Look-up a JMS Connection Factory object from JNDI on server 1
+         ConnectionFactory cf2 = (ConnectionFactory)ic2.lookup("/ConnectionFactory");
+
+         // Step 6. We create a JMS Connection connection0 which is a connection to server 0
+         connection0 = cf0.createConnection();
+
+         // Step 7. We create a JMS Connection connection1 which is a connection to server 1
+         connection1 = cf1.createConnection();
+
+         // Step 7. We create a JMS Connection connection1 which is a connection to server 1
+         connection2 = cf2.createConnection();
+
+         // Step 8. We create a JMS Session on server 0
+         Session session0 = connection0.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         // Step 9. We create a JMS Session on server 1
+         Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         // Step 10. We create a JMS Session on server 1
+         Session session2 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         // Step 11. We start the connections to ensure delivery occurs on them
+         connection0.start();
+
+         connection1.start();
+
+         connection2.start();
+
+         // Step 12. We create JMS MessageConsumer objects on server 0
+         MessageConsumer consumer = session0.createConsumer(queue);
+
+
+         // Step 13. We create a JMS MessageProducer object on server 0, 1 and 2
+         MessageProducer producer0 = session0.createProducer(queue);
+
+         MessageProducer producer1 = session1.createProducer(queue);
+
+         MessageProducer producer2 = session2.createProducer(queue);
+
+         // Step 14. We send some messages to server 0, 1 and 2 with the same groupid set
+
+         final int numMessages = 10;
+
+         for (int i = 0; i < numMessages; i++)
+         {
+            TextMessage message = session0.createTextMessage("This is text message " + i);
+
+            message.setStringProperty("JMSXGroupID", "Group-0");
+
+            producer0.send(message);
+
+            System.out.println("Sent messages: " + message.getText() + " to node 0");
+         }
+
+         for (int i = 0; i < numMessages; i++)
+         {
+            TextMessage message = session1.createTextMessage("This is text message " + (i + 10));
+
+            message.setStringProperty("JMSXGroupID", "Group-0");
+
+            producer1.send(message);
+
+            System.out.println("Sent messages: " + message.getText() + " to node 1");
+
+         }
+
+         for (int i = 0; i < numMessages; i++)
+         {
+            TextMessage message = session2.createTextMessage("This is text message " + (i + 20));
+
+            message.setStringProperty("JMSXGroupID", "Group-0");
+
+            producer2.send(message);
+
+            System.out.println("Sent messages: " + message.getText() + " to node 2");
+         }
+
+         // Step 15. We now consume those messages from server 0
+         // We note the messages have all been sent to the same consumer on the same node
+
+         for (int i = 0; i < numMessages * 3; i++)
+         {
+            TextMessage message0 = (TextMessage)consumer.receive(5000);
+
+            System.out.println("Got message: " + message0.getText() + " from node 0");
+
+         }
+
+         return true;
+      }
+      finally
+      {
+         // Step 16. Be sure to close our resources!
+
+         if (connection0 != null)
+         {
+            connection0.close();
+         }
+
+         if (connection1 != null)
+         {
+            connection1.close();
+         }
+
+         if (connection2 != null)
+         {
+            connection2.close();
+         }
+
+         if (ic0 != null)
+         {
+            ic0.close();
+         }
+
+         if (ic1 != null)
+         {
+            ic1.close();
+         }
+
+         if (ic2 != null)
+         {
+            ic2.close();
+         }
+      }
+   }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-grouping/src/main/resources/hornetq/server0/hornetq-configuration.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/src/main/resources/hornetq/server0/hornetq-configuration.xml b/examples/jms/clustered-grouping/src/main/resources/hornetq/server0/hornetq-configuration.xml
new file mode 100644
index 0000000..a5ce84b
--- /dev/null
+++ b/examples/jms/clustered-grouping/src/main/resources/hornetq/server0/hornetq-configuration.xml
@@ -0,0 +1,83 @@
+<configuration xmlns="urn:hornetq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
+   
+
+   <bindings-directory>${build.directory}/server0/data/messaging/bindings</bindings-directory>
+
+   <journal-directory>${build.directory}/server0/data/messaging/journal</journal-directory>
+
+   <large-messages-directory>${build.directory}/server0/data/messaging/largemessages</large-messages-directory>
+
+   <paging-directory>${build.directory}/server0/data/messaging/paging</paging-directory>
+
+   <!-- Connectors -->
+
+   <connectors>
+      <connector name="netty-connector">
+         <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+         <param key="port" value="5445"/>
+      </connector>
+   </connectors>
+   
+   <!-- Acceptors -->
+   <acceptors>
+      <acceptor name="netty-acceptor">
+         <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+         <param key="port" value="5445"/>
+      </acceptor>
+   </acceptors>
+   
+   <!-- Clustering configuration -->
+   <broadcast-groups>
+      <broadcast-group name="my-broadcast-group">
+         <group-address>${udp-address:231.7.7.7}</group-address>
+         <group-port>9876</group-port>
+         <broadcast-period>100</broadcast-period>
+         <connector-ref>netty-connector</connector-ref>
+     </broadcast-group>
+   </broadcast-groups>
+   
+   <discovery-groups>
+      <discovery-group name="my-discovery-group">
+         <group-address>${udp-address:231.7.7.7}</group-address>
+         <group-port>9876</group-port>
+         <refresh-timeout>10000</refresh-timeout>
+      </discovery-group>
+   </discovery-groups>
+   
+   <cluster-connections>
+      <cluster-connection name="my-cluster">
+         <address>jms</address>
+         <connector-ref>netty-connector</connector-ref>
+         <retry-interval>500</retry-interval>
+         <use-duplicate-detection>true</use-duplicate-detection>
+         <forward-when-no-consumers>true</forward-when-no-consumers>
+         <max-hops>1</max-hops>
+         <discovery-group-ref discovery-group-name="my-discovery-group"/>
+      </cluster-connection>
+   </cluster-connections>
+
+   <grouping-handler name="my-grouping-handler">
+      <type>LOCAL</type>
+      <address>jms</address>
+      <timeout>5000</timeout>
+      <group-timeout>-1</group-timeout>
+      <reaper-period>30000</reaper-period>
+   </grouping-handler>
+   
+   <!-- 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>
+
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-grouping/src/main/resources/hornetq/server0/hornetq-jms.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/src/main/resources/hornetq/server0/hornetq-jms.xml b/examples/jms/clustered-grouping/src/main/resources/hornetq/server0/hornetq-jms.xml
new file mode 100644
index 0000000..678e7f5
--- /dev/null
+++ b/examples/jms/clustered-grouping/src/main/resources/hornetq/server0/hornetq-jms.xml
@@ -0,0 +1,19 @@
+<configuration xmlns="urn:hornetq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+   <!--the connection factory used by the example-->
+   <connection-factory name="ConnectionFactory">
+      <connectors>
+         <connector-ref connector-name="netty-connector"/>
+      </connectors>
+      <entries>
+         <entry name="ConnectionFactory"/>
+      </entries>
+   </connection-factory>
+
+   <!--the queue used by the example-->
+   <queue name="exampleQueue">
+      <entry name="/queue/exampleQueue"/>
+   </queue>
+
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-grouping/src/main/resources/hornetq/server0/hornetq-users.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/src/main/resources/hornetq/server0/hornetq-users.xml b/examples/jms/clustered-grouping/src/main/resources/hornetq/server0/hornetq-users.xml
new file mode 100644
index 0000000..934306c
--- /dev/null
+++ b/examples/jms/clustered-grouping/src/main/resources/hornetq/server0/hornetq-users.xml
@@ -0,0 +1,7 @@
+<configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd">
+   <!-- the default user.  this is used where username is null-->
+   <defaultuser name="guest" password="guest">
+      <role name="guest"/>
+   </defaultuser>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-grouping/src/main/resources/hornetq/server1/hornetq-configuration.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/src/main/resources/hornetq/server1/hornetq-configuration.xml b/examples/jms/clustered-grouping/src/main/resources/hornetq/server1/hornetq-configuration.xml
new file mode 100644
index 0000000..f0432e0
--- /dev/null
+++ b/examples/jms/clustered-grouping/src/main/resources/hornetq/server1/hornetq-configuration.xml
@@ -0,0 +1,80 @@
+<configuration xmlns="urn:hornetq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
+   
+
+   <bindings-directory>${build.directory}/server1/data/messaging/bindings</bindings-directory>
+
+   <journal-directory>${build.directory}/server1/data/messaging/journal</journal-directory>
+
+   <large-messages-directory>${build.directory}/server1/data/messaging/largemessages</large-messages-directory>
+
+   <paging-directory>${build.directory}/server1/data/messaging/paging</paging-directory>
+
+   <!-- Connectors -->
+   <connectors>
+      <connector name="netty-connector">
+         <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+         <param key="port" value="5446"/>
+      </connector>
+   </connectors>
+   
+   <!-- Acceptors -->
+   <acceptors>
+      <acceptor name="netty-acceptor">
+         <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+         <param key="port" value="5446"/>
+      </acceptor>
+   </acceptors>
+   
+   <!-- Clustering configuration -->
+   <broadcast-groups>
+      <broadcast-group name="my-broadcast-group">
+         <group-address>${udp-address:231.7.7.7}</group-address>
+         <group-port>9876</group-port>
+         <broadcast-period>100</broadcast-period>
+         <connector-ref>netty-connector</connector-ref>
+      </broadcast-group>
+   </broadcast-groups>
+   
+   <discovery-groups>
+      <discovery-group name="my-discovery-group">
+         <group-address>${udp-address:231.7.7.7}</group-address>
+         <group-port>9876</group-port>
+         <refresh-timeout>10000</refresh-timeout>
+      </discovery-group>
+   </discovery-groups>
+   
+   <cluster-connections>
+      <cluster-connection name="my-cluster">
+         <address>jms</address>
+         <connector-ref>netty-connector</connector-ref>
+         <retry-interval>500</retry-interval>
+         <use-duplicate-detection>true</use-duplicate-detection>
+         <forward-when-no-consumers>true</forward-when-no-consumers>
+         <max-hops>1</max-hops>
+         <discovery-group-ref discovery-group-name="my-discovery-group"/>
+      </cluster-connection>
+   </cluster-connections>
+
+   <grouping-handler name="my-grouping-handler">
+      <type>REMOTE</type>
+      <address>jms</address>
+      <timeout>5000</timeout>
+   </grouping-handler>
+
+   <!-- 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>
+
+</configuration>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-grouping/src/main/resources/hornetq/server1/hornetq-jms.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/src/main/resources/hornetq/server1/hornetq-jms.xml b/examples/jms/clustered-grouping/src/main/resources/hornetq/server1/hornetq-jms.xml
new file mode 100644
index 0000000..678e7f5
--- /dev/null
+++ b/examples/jms/clustered-grouping/src/main/resources/hornetq/server1/hornetq-jms.xml
@@ -0,0 +1,19 @@
+<configuration xmlns="urn:hornetq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+   <!--the connection factory used by the example-->
+   <connection-factory name="ConnectionFactory">
+      <connectors>
+         <connector-ref connector-name="netty-connector"/>
+      </connectors>
+      <entries>
+         <entry name="ConnectionFactory"/>
+      </entries>
+   </connection-factory>
+
+   <!--the queue used by the example-->
+   <queue name="exampleQueue">
+      <entry name="/queue/exampleQueue"/>
+   </queue>
+
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-grouping/src/main/resources/hornetq/server1/hornetq-users.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/src/main/resources/hornetq/server1/hornetq-users.xml b/examples/jms/clustered-grouping/src/main/resources/hornetq/server1/hornetq-users.xml
new file mode 100644
index 0000000..934306c
--- /dev/null
+++ b/examples/jms/clustered-grouping/src/main/resources/hornetq/server1/hornetq-users.xml
@@ -0,0 +1,7 @@
+<configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd">
+   <!-- the default user.  this is used where username is null-->
+   <defaultuser name="guest" password="guest">
+      <role name="guest"/>
+   </defaultuser>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-grouping/src/main/resources/hornetq/server2/hornetq-configuration.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/src/main/resources/hornetq/server2/hornetq-configuration.xml b/examples/jms/clustered-grouping/src/main/resources/hornetq/server2/hornetq-configuration.xml
new file mode 100644
index 0000000..502e2fe
--- /dev/null
+++ b/examples/jms/clustered-grouping/src/main/resources/hornetq/server2/hornetq-configuration.xml
@@ -0,0 +1,80 @@
+<configuration xmlns="urn:hornetq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
+   
+
+   <bindings-directory>${build.directory}/server2/data/messaging/bindings</bindings-directory>
+
+   <journal-directory>${build.directory}/server2/data/messaging/journal</journal-directory>
+
+   <large-messages-directory>${build.directory}/server2/data/messaging/largemessages</large-messages-directory>
+
+   <paging-directory>${build.directory}/server2/data/messaging/paging</paging-directory>
+
+   <!-- Connectors -->
+   <connectors>
+      <connector name="netty-connector">
+         <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+         <param key="port" value="5447"/>
+      </connector>
+   </connectors>
+   
+   <!-- Acceptors -->
+   <acceptors>
+      <acceptor name="netty-acceptor">
+         <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+         <param key="port" value="5447"/>
+      </acceptor>
+   </acceptors>
+   
+   <!-- Clustering configuration -->
+   <broadcast-groups>
+      <broadcast-group name="my-broadcast-group">
+         <group-address>${udp-address:231.7.7.7}</group-address>
+         <group-port>9876</group-port>
+         <broadcast-period>100</broadcast-period>
+         <connector-ref>netty-connector</connector-ref>
+      </broadcast-group>
+   </broadcast-groups>
+   
+   <discovery-groups>
+      <discovery-group name="my-discovery-group">
+         <group-address>${udp-address:231.7.7.7}</group-address>
+         <group-port>9876</group-port>
+         <refresh-timeout>10000</refresh-timeout>
+      </discovery-group>
+   </discovery-groups>
+   
+   <cluster-connections>
+      <cluster-connection name="my-cluster">
+         <address>jms</address>
+         <connector-ref>netty-connector</connector-ref>
+         <retry-interval>500</retry-interval>
+         <use-duplicate-detection>true</use-duplicate-detection>
+         <forward-when-no-consumers>true</forward-when-no-consumers>
+         <max-hops>1</max-hops>
+         <discovery-group-ref discovery-group-name="my-discovery-group"/>
+      </cluster-connection>
+   </cluster-connections>
+
+   <grouping-handler name="my-grouping-handler">
+      <type>REMOTE</type>
+      <address>jms</address>
+      <timeout>5000</timeout>
+   </grouping-handler>
+
+   <!-- 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>
+
+</configuration>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-grouping/src/main/resources/hornetq/server2/hornetq-jms.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/src/main/resources/hornetq/server2/hornetq-jms.xml b/examples/jms/clustered-grouping/src/main/resources/hornetq/server2/hornetq-jms.xml
new file mode 100644
index 0000000..678e7f5
--- /dev/null
+++ b/examples/jms/clustered-grouping/src/main/resources/hornetq/server2/hornetq-jms.xml
@@ -0,0 +1,19 @@
+<configuration xmlns="urn:hornetq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+   <!--the connection factory used by the example-->
+   <connection-factory name="ConnectionFactory">
+      <connectors>
+         <connector-ref connector-name="netty-connector"/>
+      </connectors>
+      <entries>
+         <entry name="ConnectionFactory"/>
+      </entries>
+   </connection-factory>
+
+   <!--the queue used by the example-->
+   <queue name="exampleQueue">
+      <entry name="/queue/exampleQueue"/>
+   </queue>
+
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-grouping/src/main/resources/hornetq/server2/hornetq-users.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/src/main/resources/hornetq/server2/hornetq-users.xml b/examples/jms/clustered-grouping/src/main/resources/hornetq/server2/hornetq-users.xml
new file mode 100644
index 0000000..934306c
--- /dev/null
+++ b/examples/jms/clustered-grouping/src/main/resources/hornetq/server2/hornetq-users.xml
@@ -0,0 +1,7 @@
+<configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd">
+   <!-- the default user.  this is used where username is null-->
+   <defaultuser name="guest" password="guest">
+      <role name="guest"/>
+   </defaultuser>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/pom.xml b/examples/jms/clustered-jgroups/pom.xml
new file mode 100644
index 0000000..db7e4b5
--- /dev/null
+++ b/examples/jms/clustered-jgroups/pom.xml
@@ -0,0 +1,151 @@
+<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.hornetq.examples.jms</groupId>
+      <artifactId>jms-examples</artifactId>
+      <version>2.5.0-SNAPSHOT</version>
+   </parent>
+
+   <artifactId>clustered-jgroups</artifactId>
+   <packaging>jar</packaging>
+   <name>HornetQ JMS Clustered JGroups Example</name>
+
+   <dependencies>
+      <dependency>
+         <groupId>org.hornetq.examples.jms</groupId>
+         <artifactId>hornetq-jms-examples-common</artifactId>
+         <version>${project.version}</version>
+      </dependency>
+      <dependency>
+         <groupId>org.jboss.spec.javax.jms</groupId>
+         <artifactId>jboss-jms-api_2.0_spec</artifactId>
+      </dependency>
+   </dependencies>
+
+   <build>
+      <plugins>
+         <plugin>
+            <groupId>org.hornetq</groupId>
+            <artifactId>hornetq-maven-plugin</artifactId>
+            <executions>
+               <execution>
+                  <id>start0</id>
+                  <goals>
+                     <goal>start</goal>
+                  </goals>
+                  <configuration>
+                     <hornetqConfigurationDir>${basedir}/target/classes/hornetq/server0</hornetqConfigurationDir>
+                     <systemProperties>
+                        <!-- this is to make sure the example will run fine on any box.
+                             you may tweak this to any property you like. More information on the JGroups docs  -->
+                        <property>
+                           <name>jgroups.bind_addr</name>
+                           <value>::1</value>
+                        </property>
+                     </systemProperties>
+                  </configuration>
+               </execution>
+               <execution>
+                  <id>start1</id>
+                  <goals>
+                     <goal>start</goal>
+                  </goals>
+                  <configuration>
+                     <jndiPort>1199</jndiPort>
+                     <jndiRmiPort>1198</jndiRmiPort>
+                     <hornetqConfigurationDir>${basedir}/target/classes/hornetq/server1</hornetqConfigurationDir>
+                     <fork>true</fork>
+                     <systemProperties>
+                        <!-- this is to make sure the example will run fine on any box. 
+                             you may tweak this to any property you like. More information on the JGroups docs  -->
+                        <property>
+                           <name>jgroups.bind_addr</name>
+                           <value>::1</value>
+                        </property>
+                     </systemProperties>
+                  </configuration>
+               </execution>
+               <execution>
+                  <id>runClient</id>
+                  <goals>
+                     <goal>runClient</goal>
+                  </goals>
+                  <configuration>
+                     <clientClass>org.hornetq.jms.example.ClusteredJgroupsExample</clientClass>
+                     <args>
+                        <param>jnp://localhost:1099</param>
+                        <param>jnp://localhost:1199</param>
+                     </args>
+                  </configuration>
+               </execution>
+               <execution>
+                  <id>stop0</id>
+                  <goals>
+                     <goal>stop</goal>
+                  </goals>
+                  <configuration>
+                     <hornetqConfigurationDir>${basedir}/target/classes/hornetq/server0</hornetqConfigurationDir>
+                  </configuration>
+               </execution>
+               <execution>
+                  <id>stop1</id>
+                  <goals>
+                     <goal>stop</goal>
+                  </goals>
+                  <configuration>
+                     <hornetqConfigurationDir>${basedir}/target/classes/hornetq/server1</hornetqConfigurationDir>
+                  </configuration>
+               </execution>
+            </executions>
+            <dependencies>
+               <dependency>
+                  <groupId>org.hornetq.examples.jms</groupId>
+                  <artifactId>clustered-jgroups</artifactId>
+                  <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                  <groupId>org.hornetq</groupId>
+                  <artifactId>hornetq-core-client</artifactId>
+                  <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                  <groupId>org.hornetq</groupId>
+                  <artifactId>hornetq-server</artifactId>
+                  <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                  <groupId>org.hornetq</groupId>
+                  <artifactId>hornetq-jms-client</artifactId>
+                  <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                  <groupId>org.hornetq</groupId>
+                  <artifactId>hornetq-jms-server</artifactId>
+                  <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                  <groupId>io.netty</groupId>
+                  <artifactId>netty-all</artifactId>
+                  <version>${netty.version}</version>
+               </dependency>
+               <dependency>
+                  <groupId>org.jboss.javaee</groupId>
+                  <artifactId>jboss-jms-api</artifactId>
+                  <version>1.1.0.GA</version>
+               </dependency>
+               <dependency>
+                  <groupId>org.jboss.naming</groupId>
+                  <artifactId>jnpserver</artifactId>
+                  <version>5.0.3.GA</version>
+               </dependency>
+            </dependencies>
+            <configuration>
+               <waitOnStart>false</waitOnStart>
+            </configuration>
+         </plugin>
+      </plugins>
+   </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/readme.html
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/readme.html b/examples/jms/clustered-jgroups/readme.html
new file mode 100644
index 0000000..bf1c661
--- /dev/null
+++ b/examples/jms/clustered-jgroups/readme.html
@@ -0,0 +1,188 @@
+<html>
+  <head>
+    <title>HornetQ Clustering with JGroups 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>HornetQ Clustering with JGroups Example</h1>
+
+     <p>This example demonstrates the working of a two node cluster using JGroups as the underlying topology broadcasting/discovery 
+     technique.</p>
+     <p>We deploy a queue on to the cluster, then create a consumer on the queue on each node, and we create a producer on only one of the nodes.</p>
+     <p>We then send some messages via the producer, and we verify that <b>both</b> consumers receive the sent messages
+     in a round-robin fashion.</p>
+     <p>This example uses JNDI to lookup the JMS Queue and ConnectionFactory objects. If you prefer not to use
+     JNDI, these could be instantiated directly.</p>
+     <p>To enable HornetQ to use JGroups you need to configure JGroups configuration file and make sure it is on the classpath
+         by placing in the configuration directory, the file test-jgroups-file_ping.xml is the configuration used in this
+     exaample</p>
+     <p>You then configure the jgroups file used by the broadcast and discovery groups in the configuration along with the
+         channel name which you want this cluster to share.</p>
+     <pre class="prettyprint">
+     <code>
+   &lt;broadcast-groups&gt;
+      &lt;broadcast-group name="my-broadcast-group">
+         &lt;broadcast-period>5000&lt;/broadcast-period>
+         &lt;jgroups-file>test-jgroups-file_ping.xml&lt;/jgroups-file>
+         &lt;jgroups-channel>hornetq_broadcast_channel&lt;/jgroups-channel>
+         &lt;connector-ref>netty-connector&lt;/connector-ref>
+      &lt;/broadcast-group>
+   &lt;/broadcast-groups&gt;
+
+   &lt;discovery-groups&gt;
+      &lt;discovery-group name="my-discovery-group">
+         &lt;jgroups-file>test-jgroups-file_ping.xml&lt;/jgroups-file>
+         &lt;jgroups-channel>hornetq_broadcast_channel&lt;/jgroups-channel>
+         &lt;refresh-timeout>10000&lt;/refresh-timeout>
+      &lt;/discovery-group>
+   &lt;/discovery-groups&gt;
+     </code>
+     </pre>    
+     <p>For more information on HornetQ clustering in general, please see the clustering
+     section of the user manual.</p>      
+     <h2>Example step-by-step</h2>
+     <p><i>To run the example, simply type <code>./build.sh</code> (or <code>build.bat</code> on windows) from this directory</i></p>
+
+     <ol>
+        <li> Get an initial context for looking up JNDI from server 0.</li>
+        <pre class="prettyprint">
+           <code>
+   ic0 = getContext(0);
+   </code>
+        </pre>
+
+        <li>Look-up the JMS Queue object from JNDI</li>
+        <pre class="prettyprint">
+           <code>Queue queue = (Queue)ic0.lookup("/queue/exampleQueue");</code>
+        </pre>
+
+        <li>Look-up a JMS Connection Factory object from JNDI on server 0</li>
+        <pre class="prettyprint">
+           <code>ConnectionFactory cf0 = (ConnectionFactory)ic0.lookup("/ConnectionFactory");</code>
+        </pre>
+
+        <li>Get an initial context for looking up JNDI from server 1.</li>
+        <pre class="prettyprint">
+           <code>ic1 = getContext(1);</code>
+        </pre>
+
+        <li>Look-up a JMS Connection Factory object from JNDI on server 1</li>
+        <pre class="prettyprint">
+           <code>ConnectionFactory cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
+           </code>
+        </pre>
+
+        <li>We create a JMS Connection connection0 which is a connection to server 0</li>
+        <pre class="prettyprint">
+          <code>
+   connection0 = cf0.createConnection();
+          </code>
+        </pre>
+        
+        <li>We create a JMS Connection connection1 which is a connection to server 1</li>
+        <pre class="prettyprint">
+          <code>
+   connection1 = cf1.createConnection();
+          </code>
+        </pre>
+
+        <li>We create a JMS Session on server 0</li>
+        <pre class="prettyprint">
+           <code>
+   Session session0 = connection0.createSession(false, Session.AUTO_ACKNOWLEDGE);
+           </code>
+        </pre>
+        
+        <li>We create a JMS Session on server 1</li>
+        <pre class="prettyprint">
+           <code>
+   Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            </code>
+        </pre>
+
+        <li>We start the connections to ensure delivery occurs on them</li>
+        <pre class="prettyprint">
+           <code>
+   connection0.start();
+
+   connection1.start();
+           </code>
+        </pre>
+
+        <li>We create JMS MessageConsumer objects on server 0 and server 1</li>
+        <pre class="prettyprint">
+           <code>
+   MessageConsumer consumer0 = session0.createConsumer(queue);
+
+   MessageConsumer consumer1 = session1.createConsumer(queue);
+           </code>
+        </pre>
+
+        <li>We create a JMS MessageProducer object on server 0.</li>
+        <pre class="prettyprint">
+           <code>
+   MessageProducer producer = session0.createProducer(queue);</code>
+        </pre>
+
+        <li>We send some messages to server 0.</li>
+        <pre class="prettyprint">
+           <code>
+	final int numMessages = 10;
+
+	for (int i = 0; i < numMessages; i++)
+	{
+	   TextMessage message = session0.createTextMessage("This is text message " + i);
+	      
+	   producer.send(message);
+	
+	   System.out.println("Sent message: " + message.getText());
+	}
+           </code>
+        </pre>
+        
+        <li>We now consume those messages on *both* server 0 and server 1.
+         We note the messages have been distributed between servers in a round robin fashion.
+         HornetQ has <b>load balanced</b> the messages between the available consumers on the different nodes.
+         HornetQ can be configured to always load balance messages to all nodes, or to only balance messages
+         to nodes which have consumers with no or matching selectors. See the user manual for more details.</li>
+         JMS Queues implement point-to-point message where each message is only ever consumed by a
+         maximum of one consumer.
+        <pre class="prettyprint">
+           <code>
+	for (int i = 0; i < numMessages; i += 2)
+	{
+	   TextMessage message0 = (TextMessage)consumer0.receive(5000);
+	
+	   System.out.println("Got message: " + message0.getText() + " from node 0");
+	
+	   TextMessage message1 = (TextMessage)consumer1.receive(5000);
+	
+	   System.out.println("Got message: " + message1.getText() + " from node 1");
+	}
+           </code>
+        </pre> 
+
+        <li>And finally (no pun intended), <b>always</b> remember to close your JMS 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 (connection0 != null)
+	   {
+	      connection0.close();
+	   }
+	      
+	   if (connection1 != null)
+	   {
+	      connection1.close();
+	   }
+	}
+           </code>
+        </pre>
+
+     </ol>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/src/main/java/org/hornetq/jms/example/ClusteredJgroupsExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/java/org/hornetq/jms/example/ClusteredJgroupsExample.java b/examples/jms/clustered-jgroups/src/main/java/org/hornetq/jms/example/ClusteredJgroupsExample.java
new file mode 100644
index 0000000..9cb3395
--- /dev/null
+++ b/examples/jms/clustered-jgroups/src/main/java/org/hornetq/jms/example/ClusteredJgroupsExample.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat 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.hornetq.jms.example;
+
+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.jms.TextMessage;
+import javax.naming.InitialContext;
+
+import org.hornetq.common.example.HornetQExample;
+
+/**
+ * A simple example that demonstrates clustering using jgroups.
+ *
+ * @author <a href="tim.fox@jboss.com>Tim Fox</a>
+ * @author <a href="hgao@redhat.com>Howard Gao</a>
+ */
+public class ClusteredJgroupsExample extends HornetQExample
+{
+   public static void main(final String[] args)
+   {
+      new ClusteredJgroupsExample().run(args);
+   }
+
+   @Override
+   public boolean runExample() throws Exception
+   {
+      Connection connection0 = null;
+
+      Connection connection1 = null;
+
+      InitialContext ic0 = null;
+
+      InitialContext ic1 = null;
+
+      try
+      {
+         // Step 1. Get an initial context for looking up JNDI from server 0
+         ic0 = getContext(0);
+
+         // Step 2. Look-up the JMS Queue object from JNDI
+         Queue queue = (Queue)ic0.lookup("/queue/exampleQueue");
+
+         // Step 3. Look-up a JMS Connection Factory object from JNDI on server 0
+         ConnectionFactory cf0 = (ConnectionFactory)ic0.lookup("/ConnectionFactory");
+
+         // Step 4. Get an initial context for looking up JNDI from server 1
+         ic1 = getContext(1);
+
+         // Step 5. Look-up a JMS Connection Factory object from JNDI on server 1
+         ConnectionFactory cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
+
+         // Step 6. We create a JMS Connection connection0 which is a connection to server 0
+         connection0 = cf0.createConnection();
+
+         // Step 7. We create a JMS Connection connection1 which is a connection to server 1
+         connection1 = cf1.createConnection();
+
+         // Step 8. We create a JMS Session on server 0
+         Session session0 = connection0.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         // Step 9. We create a JMS Session on server 1
+         Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         // Step 10. We start the connections to ensure delivery occurs on them
+         connection0.start();
+
+         connection1.start();
+
+         // Step 11. We create JMS MessageConsumer objects on server 0 and server 1
+         MessageConsumer consumer0 = session0.createConsumer(queue);
+
+         MessageConsumer consumer1 = session1.createConsumer(queue);
+
+         Thread.sleep(1000);
+
+         // Step 12. We create a JMS MessageProducer object on server 0
+         MessageProducer producer = session0.createProducer(queue);
+
+         // Step 13. We send some messages to server 0
+
+         final int numMessages = 10;
+
+         for (int i = 0; i < numMessages; i++)
+         {
+            TextMessage message = session0.createTextMessage("This is text message " + i);
+
+            producer.send(message);
+
+            System.out.println("Sent message: " + message.getText());
+         }
+
+         // Step 14. We now consume those messages on *both* server 0 and server 1.
+         // We note the messages have been distributed between servers in a round robin fashion
+         // JMS Queues implement point-to-point message where each message is only ever consumed by a
+         // maximum of one consumer
+
+         for (int i = 0; i < numMessages; i += 2)
+         {
+            TextMessage message0 = (TextMessage)consumer0.receive(5000);
+
+            System.out.println("Got message: " + message0.getText() + " from node 0");
+
+            TextMessage message1 = (TextMessage)consumer1.receive(5000);
+
+            System.out.println("Got message: " + message1.getText() + " from node 1");
+         }
+
+         return true;
+      }
+      finally
+      {
+         // Step 15. Be sure to close our resources!
+
+         if (connection0 != null)
+         {
+            connection0.close();
+         }
+
+         if (connection1 != null)
+         {
+            connection1.close();
+         }
+
+         if (ic0 != null)
+         {
+            ic0.close();
+         }
+
+         if (ic1 != null)
+         {
+            ic1.close();
+         }
+      }
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/client-jndi.properties
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/client-jndi.properties b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/client-jndi.properties
new file mode 100644
index 0000000..080524f
--- /dev/null
+++ b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/client-jndi.properties
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-beans.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-beans.xml b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-beans.xml
new file mode 100644
index 0000000..61c04e6
--- /dev/null
+++ b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-beans.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="Naming" class="org.jnp.server.NamingBeanImpl"/>
+
+   <!-- JNDI server. Disable this if you don't want JNDI -->
+   <bean name="JNDIServer" class="org.jnp.server.Main">
+      <property name="namingInfo">
+         <inject bean="Naming"/>
+      </property>
+      <property name="port">1099</property>
+      <property name="bindAddress">localhost</property>
+      <property name="rmiPort">1098</property>
+      <property name="rmiBindAddress">localhost</property>
+   </bean>
+   
+   <!-- MBean server -->
+   <bean name="MBeanServer" class="javax.management.MBeanServer">
+      <constructor factoryClass="java.lang.management.ManagementFactory"
+                   factoryMethod="getPlatformMBeanServer"/>
+   </bean> 
+
+   <!-- The core configuration -->
+   <bean name="Configuration" class="org.hornetq.core.config.impl.FileConfiguration"/>
+
+	<!-- The security manager -->
+   <bean name="HornetQSecurityManager" class="org.hornetq.spi.core.security.HornetQSecurityManagerImpl">
+      <start ignored="true"/>
+      <stop ignored="true"/>
+   </bean>
+
+	<!-- The core server -->
+   <bean name="HornetQServer" class="org.hornetq.core.server.impl.HornetQServerImpl">
+      <constructor>
+         <parameter>
+            <inject bean="Configuration"/>
+         </parameter>
+         <parameter>
+            <inject bean="MBeanServer"/>
+         </parameter>
+         <parameter>
+            <inject bean="HornetQSecurityManager"/>
+         </parameter>        
+      </constructor>
+      <start ignored="true"/>
+      <stop ignored="true"/>
+   </bean>
+   
+   <!-- The JMS server -->
+   <bean name="JMSServerManager" class="org.hornetq.jms.server.impl.JMSServerManagerImpl">
+      <constructor>         
+         <parameter>
+            <inject bean="HornetQServer"/>
+         </parameter>
+      </constructor>
+   </bean>
+
+
+</deployment>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-configuration.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-configuration.xml b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-configuration.xml
new file mode 100644
index 0000000..9e7bb79
--- /dev/null
+++ b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-configuration.xml
@@ -0,0 +1,76 @@
+<configuration xmlns="urn:hornetq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
+   
+
+   <paging-directory>server0/paging</paging-directory>
+   
+   <bindings-directory>server0/bindings</bindings-directory>
+   
+   <journal-directory>server0/journal</journal-directory>
+   
+   <large-messages-directory>server0/large-messages</large-messages-directory>
+
+   <!-- Connectors -->
+
+   <connectors>
+      <connector name="netty-connector">
+         <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+         <param key="port" value="5445"/>
+      </connector>
+   </connectors>
+   
+   <!-- Acceptors -->
+   <acceptors>
+      <acceptor name="netty-acceptor">
+         <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+         <param key="port" value="5445"/>
+      </acceptor>
+   </acceptors>
+   
+   <!-- Clustering configuration -->
+
+   <broadcast-groups>
+      <broadcast-group name="my-broadcast-group">
+         <broadcast-period>5000</broadcast-period>
+         <jgroups-file>test-jgroups-file_ping.xml</jgroups-file>
+         <jgroups-channel>hornetq_broadcast_channel</jgroups-channel>
+         <connector-ref>netty-connector</connector-ref>
+      </broadcast-group>
+   </broadcast-groups>
+
+   <discovery-groups>
+      <discovery-group name="my-discovery-group">
+         <jgroups-file>test-jgroups-file_ping.xml</jgroups-file>
+         <jgroups-channel>hornetq_broadcast_channel</jgroups-channel>
+         <refresh-timeout>10000</refresh-timeout>
+      </discovery-group>
+   </discovery-groups>
+   
+   <cluster-connections>
+      <cluster-connection name="my-cluster">
+         <address>jms</address>
+         <connector-ref>netty-connector</connector-ref>
+         <retry-interval>500</retry-interval>
+         <use-duplicate-detection>true</use-duplicate-detection>
+         <forward-when-no-consumers>true</forward-when-no-consumers>
+         <max-hops>1</max-hops>
+         <discovery-group-ref discovery-group-name="my-discovery-group"/>
+      </cluster-connection>
+   </cluster-connections>
+   
+   <!-- 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>
+
+</configuration>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-jms.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-jms.xml b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-jms.xml
new file mode 100644
index 0000000..678e7f5
--- /dev/null
+++ b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-jms.xml
@@ -0,0 +1,19 @@
+<configuration xmlns="urn:hornetq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+   <!--the connection factory used by the example-->
+   <connection-factory name="ConnectionFactory">
+      <connectors>
+         <connector-ref connector-name="netty-connector"/>
+      </connectors>
+      <entries>
+         <entry name="ConnectionFactory"/>
+      </entries>
+   </connection-factory>
+
+   <!--the queue used by the example-->
+   <queue name="exampleQueue">
+      <entry name="/queue/exampleQueue"/>
+   </queue>
+
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-users.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-users.xml b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-users.xml
new file mode 100644
index 0000000..934306c
--- /dev/null
+++ b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/hornetq-users.xml
@@ -0,0 +1,7 @@
+<configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd">
+   <!-- the default user.  this is used where username is null-->
+   <defaultuser name="guest" password="guest">
+      <role name="guest"/>
+   </defaultuser>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/test-jgroups-file_ping.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/test-jgroups-file_ping.xml b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/test-jgroups-file_ping.xml
new file mode 100644
index 0000000..269e06e
--- /dev/null
+++ b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server0/test-jgroups-file_ping.xml
@@ -0,0 +1,52 @@
+<config xmlns="urn:org:jgroups"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="urn:org:jgroups file:schema/JGroups-2.8.xsd">
+    <TCP loopback="true"
+         recv_buf_size="20000000"
+         send_buf_size="640000"
+         discard_incompatible_packets="true"
+         max_bundle_size="64000"
+         max_bundle_timeout="30"
+         enable_bundling="true"
+         use_send_queues="false"
+         sock_conn_timeout="300"
+
+         thread_pool.enabled="true"
+         thread_pool.min_threads="1"
+         thread_pool.max_threads="10"
+         thread_pool.keep_alive_time="5000"
+         thread_pool.queue_enabled="false"
+         thread_pool.queue_max_size="100"
+         thread_pool.rejection_policy="run"
+
+         oob_thread_pool.enabled="true"
+         oob_thread_pool.min_threads="1"
+         oob_thread_pool.max_threads="8"
+         oob_thread_pool.keep_alive_time="5000"
+         oob_thread_pool.queue_enabled="false"
+         oob_thread_pool.queue_max_size="100"
+         oob_thread_pool.rejection_policy="run"/>
+
+    <FILE_PING location="../file.ping.dir"/>
+    <MERGE2 max_interval="30000"
+              min_interval="10000"/>
+    <FD_SOCK/>
+    <FD timeout="10000" max_tries="5" />
+    <VERIFY_SUSPECT timeout="1500"  />
+    <BARRIER />
+    <pbcast.NAKACK
+                   use_mcast_xmit="false"
+                   retransmit_timeout="300,600,1200,2400,4800"
+                   discard_delivered_msgs="true"/>
+    <UNICAST timeout="300,600,1200" />
+    <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+                   max_bytes="400000"/>
+    <pbcast.GMS print_local_addr="true" join_timeout="3000"
+
+                view_bundling="true"/>
+    <FC max_credits="2000000"
+        min_threshold="0.10"/>
+    <FRAG2 frag_size="60000"  />
+    <pbcast.STATE_TRANSFER/>
+    <pbcast.FLUSH timeout="0"/>
+</config>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/client-jndi.properties
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/client-jndi.properties b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/client-jndi.properties
new file mode 100644
index 0000000..7bcaf95
--- /dev/null
+++ b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/client-jndi.properties
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:2099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-beans.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-beans.xml b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-beans.xml
new file mode 100644
index 0000000..e5fe1e0
--- /dev/null
+++ b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-beans.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="Naming" class="org.jnp.server.NamingBeanImpl"/>
+
+   <!-- JNDI server. Disable this if you don't want JNDI -->
+   <bean name="JNDIServer" class="org.jnp.server.Main">
+      <property name="namingInfo">
+         <inject bean="Naming"/>
+      </property>
+      <property name="port">2099</property>
+      <property name="bindAddress">localhost</property>
+      <property name="rmiPort">2098</property>
+      <property name="rmiBindAddress">localhost</property>
+   </bean>
+   
+   <!-- MBean server -->
+   <bean name="MBeanServer" class="javax.management.MBeanServer">
+      <constructor factoryClass="java.lang.management.ManagementFactory"
+                   factoryMethod="getPlatformMBeanServer"/>
+   </bean> 
+
+   <!-- The core configuration -->
+   <bean name="Configuration" class="org.hornetq.core.config.impl.FileConfiguration"/>
+
+	<!-- The security manager -->
+   <bean name="HornetQSecurityManager" class="org.hornetq.spi.core.security.HornetQSecurityManagerImpl">
+      <start ignored="true"/>
+      <stop ignored="true"/>
+   </bean>
+
+	<!-- The core server -->
+   <bean name="HornetQServer" class="org.hornetq.core.server.impl.HornetQServerImpl">
+      <constructor>
+         <parameter>
+            <inject bean="Configuration"/>
+         </parameter>
+         <parameter>
+            <inject bean="MBeanServer"/>
+         </parameter>
+         <parameter>
+            <inject bean="HornetQSecurityManager"/>
+         </parameter>        
+      </constructor>
+      <start ignored="true"/>
+      <stop ignored="true"/>
+   </bean>
+   
+   <!-- The JMS server -->
+   <bean name="JMSServerManager" class="org.hornetq.jms.server.impl.JMSServerManagerImpl">
+      <constructor>         
+         <parameter>
+            <inject bean="HornetQServer"/>
+         </parameter>
+      </constructor>
+   </bean>
+
+</deployment>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-configuration.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-configuration.xml b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-configuration.xml
new file mode 100644
index 0000000..d3525a7
--- /dev/null
+++ b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-configuration.xml
@@ -0,0 +1,75 @@
+<configuration xmlns="urn:hornetq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
+   
+
+   <paging-directory>server1/paging</paging-directory>
+   
+   <bindings-directory>server1/bindings</bindings-directory>
+   
+   <journal-directory>server1/journal</journal-directory>
+   
+   <large-messages-directory>server1/large-messages</large-messages-directory>
+
+   <!-- Connectors -->
+   <connectors>
+      <connector name="netty-connector">
+         <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+         <param key="port" value="5446"/>
+      </connector>
+   </connectors>
+   
+   <!-- Acceptors -->
+   <acceptors>
+      <acceptor name="netty-acceptor">
+         <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+         <param key="port" value="5446"/>
+      </acceptor>
+   </acceptors>
+   
+   <!-- Clustering configuration -->
+
+   <broadcast-groups>
+      <broadcast-group name="my-broadcast-group">
+         <broadcast-period>5000</broadcast-period>
+         <jgroups-file>test-jgroups-file_ping.xml</jgroups-file>
+         <jgroups-channel>hornetq_broadcast_channel</jgroups-channel>
+         <connector-ref>netty-connector</connector-ref>
+      </broadcast-group>
+   </broadcast-groups>
+
+   <discovery-groups>
+      <discovery-group name="my-discovery-group">
+         <jgroups-file>test-jgroups-file_ping.xml</jgroups-file>
+         <jgroups-channel>hornetq_broadcast_channel</jgroups-channel>
+         <refresh-timeout>10000</refresh-timeout>
+      </discovery-group>
+   </discovery-groups>
+   
+   <cluster-connections>
+      <cluster-connection name="my-cluster">
+         <address>jms</address>
+         <connector-ref>netty-connector</connector-ref>
+         <retry-interval>500</retry-interval>
+         <use-duplicate-detection>true</use-duplicate-detection>
+         <forward-when-no-consumers>true</forward-when-no-consumers>
+         <max-hops>1</max-hops>
+         <discovery-group-ref discovery-group-name="my-discovery-group"/>
+      </cluster-connection>
+   </cluster-connections>
+   
+   <!-- 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>
+
+</configuration>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-jms.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-jms.xml b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-jms.xml
new file mode 100644
index 0000000..678e7f5
--- /dev/null
+++ b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-jms.xml
@@ -0,0 +1,19 @@
+<configuration xmlns="urn:hornetq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+   <!--the connection factory used by the example-->
+   <connection-factory name="ConnectionFactory">
+      <connectors>
+         <connector-ref connector-name="netty-connector"/>
+      </connectors>
+      <entries>
+         <entry name="ConnectionFactory"/>
+      </entries>
+   </connection-factory>
+
+   <!--the queue used by the example-->
+   <queue name="exampleQueue">
+      <entry name="/queue/exampleQueue"/>
+   </queue>
+
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-users.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-users.xml b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-users.xml
new file mode 100644
index 0000000..934306c
--- /dev/null
+++ b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/hornetq-users.xml
@@ -0,0 +1,7 @@
+<configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd">
+   <!-- the default user.  this is used where username is null-->
+   <defaultuser name="guest" password="guest">
+      <role name="guest"/>
+   </defaultuser>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/test-jgroups-file_ping.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/test-jgroups-file_ping.xml b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/test-jgroups-file_ping.xml
new file mode 100644
index 0000000..38ad144
--- /dev/null
+++ b/examples/jms/clustered-jgroups/src/main/resources/hornetq/server1/test-jgroups-file_ping.xml
@@ -0,0 +1,52 @@
+<config xmlns="urn:org:jgroups"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/JGroups-3.0.xsd">
+    <TCP loopback="true"
+         recv_buf_size="20000000"
+         send_buf_size="640000"
+         discard_incompatible_packets="true"
+         max_bundle_size="64000"
+         max_bundle_timeout="30"
+         enable_bundling="true"
+         use_send_queues="false"
+         sock_conn_timeout="300"
+
+         thread_pool.enabled="true"
+         thread_pool.min_threads="1"
+         thread_pool.max_threads="10"
+         thread_pool.keep_alive_time="5000"
+         thread_pool.queue_enabled="false"
+         thread_pool.queue_max_size="100"
+         thread_pool.rejection_policy="run"
+
+         oob_thread_pool.enabled="true"
+         oob_thread_pool.min_threads="1"
+         oob_thread_pool.max_threads="8"
+         oob_thread_pool.keep_alive_time="5000"
+         oob_thread_pool.queue_enabled="false"
+         oob_thread_pool.queue_max_size="100"
+         oob_thread_pool.rejection_policy="run"/>
+
+    <FILE_PING location="../file.ping.dir"/>
+    <MERGE2 max_interval="30000"
+              min_interval="10000"/>
+    <FD_SOCK/>
+    <FD timeout="10000" max_tries="5" />
+    <VERIFY_SUSPECT timeout="1500"  />
+    <BARRIER />
+    <pbcast.NAKACK
+                   use_mcast_xmit="false"
+                   retransmit_timeout="300,600,1200,2400,4800"
+                   discard_delivered_msgs="true"/>
+    <UNICAST timeout="300,600,1200" />
+    <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+                   max_bytes="400000"/>
+    <pbcast.GMS print_local_addr="true" join_timeout="3000"
+
+                view_bundling="true"/>
+    <FC max_credits="2000000"
+        min_threshold="0.10"/>
+    <FRAG2 frag_size="60000"  />
+    <pbcast.STATE_TRANSFER/>
+    <pbcast.FLUSH timeout="0"/>
+</config>


Mime
View raw message