[hornetq-commits] JBoss hornetq SVN: r10021 - in trunk/examples/jms/clustered-static-discovery: server0 and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Dec 9 11:47:57 EST 2010


Author: ataylor
Date: 2010-12-09 11:47:56 -0500 (Thu, 09 Dec 2010)
New Revision: 10021

Added:
   trunk/examples/jms/clustered-static-discovery/server2/
   trunk/examples/jms/clustered-static-discovery/server2/client-jndi.properties
   trunk/examples/jms/clustered-static-discovery/server2/hornetq-beans.xml
   trunk/examples/jms/clustered-static-discovery/server2/hornetq-configuration.xml
   trunk/examples/jms/clustered-static-discovery/server2/hornetq-jms.xml
   trunk/examples/jms/clustered-static-discovery/server2/hornetq-users.xml
   trunk/examples/jms/clustered-static-discovery/server2/jndi.properties
   trunk/examples/jms/clustered-static-discovery/server3/
   trunk/examples/jms/clustered-static-discovery/server3/client-jndi.properties
   trunk/examples/jms/clustered-static-discovery/server3/hornetq-beans.xml
   trunk/examples/jms/clustered-static-discovery/server3/hornetq-configuration.xml
   trunk/examples/jms/clustered-static-discovery/server3/hornetq-jms.xml
   trunk/examples/jms/clustered-static-discovery/server3/hornetq-users.xml
   trunk/examples/jms/clustered-static-discovery/server3/jndi.properties
Modified:
   trunk/examples/jms/clustered-static-discovery/build.xml
   trunk/examples/jms/clustered-static-discovery/server0/hornetq-jms.xml
   trunk/examples/jms/clustered-static-discovery/server1/hornetq-jms.xml
   trunk/examples/jms/clustered-static-discovery/src/org/hornetq/jms/example/StaticClusteredQueueExample.java
Log:
updated static discovery example

Modified: trunk/examples/jms/clustered-static-discovery/build.xml
===================================================================
--- trunk/examples/jms/clustered-static-discovery/build.xml	2010-12-09 15:01:09 UTC (rev 10020)
+++ trunk/examples/jms/clustered-static-discovery/build.xml	2010-12-09 16:47:56 UTC (rev 10021)
@@ -21,7 +21,7 @@
    <target name="run">
       <antcall target="runExample">
          <param name="example.classname" value="org.hornetq.jms.example.StaticClusteredQueueExample"/>
-         <param name="hornetq.example.beans.file" value="server0 server1"/>
+         <param name="hornetq.example.beans.file" value="server0 server1 server2 server3"/>
       </antcall>
    </target>
 

Modified: trunk/examples/jms/clustered-static-discovery/server0/hornetq-jms.xml
===================================================================
--- trunk/examples/jms/clustered-static-discovery/server0/hornetq-jms.xml	2010-12-09 15:01:09 UTC (rev 10020)
+++ trunk/examples/jms/clustered-static-discovery/server0/hornetq-jms.xml	2010-12-09 16:47:56 UTC (rev 10021)
@@ -9,6 +9,18 @@
       <entries>
          <entry name="ConnectionFactory"/>
       </entries>
+
+      <ha>true</ha>
+      <!-- Pause 1 second between connect attempts -->
+      <retry-interval>1000</retry-interval>
+
+      <!-- Multiply subsequent reconnect pauses by this multiplier. This can be used to
+      implement an exponential back-off. For our purposes we just set to 1.0 so each reconnect
+      pause is the same length -->
+      <retry-interval-multiplier>1.0</retry-interval-multiplier>
+
+      <!-- Try reconnecting an unlimited number of times (-1 means "unlimited") -->
+      <reconnect-attempts>-1</reconnect-attempts>
    </connection-factory>
 
    <!--the queue used by the example-->

Modified: trunk/examples/jms/clustered-static-discovery/server1/hornetq-jms.xml
===================================================================
--- trunk/examples/jms/clustered-static-discovery/server1/hornetq-jms.xml	2010-12-09 15:01:09 UTC (rev 10020)
+++ trunk/examples/jms/clustered-static-discovery/server1/hornetq-jms.xml	2010-12-09 16:47:56 UTC (rev 10021)
@@ -9,6 +9,18 @@
       <entries>
          <entry name="ConnectionFactory"/>
       </entries>
+
+      <ha>true</ha>
+      <!-- Pause 1 second between connect attempts -->
+      <retry-interval>1000</retry-interval>
+
+      <!-- Multiply subsequent reconnect pauses by this multiplier. This can be used to
+      implement an exponential back-off. For our purposes we just set to 1.0 so each reconnect
+      pause is the same length -->
+      <retry-interval-multiplier>1.0</retry-interval-multiplier>
+
+      <!-- Try reconnecting an unlimited number of times (-1 means "unlimited") -->
+      <reconnect-attempts>-1</reconnect-attempts>
    </connection-factory>
 
    <!--the queue used by the example-->

Copied: trunk/examples/jms/clustered-static-discovery/server2/client-jndi.properties (from rev 10019, trunk/examples/jms/clustered-static-discovery/server1/client-jndi.properties)
===================================================================
--- trunk/examples/jms/clustered-static-discovery/server2/client-jndi.properties	                        (rev 0)
+++ trunk/examples/jms/clustered-static-discovery/server2/client-jndi.properties	2010-12-09 16:47:56 UTC (rev 10021)
@@ -0,0 +1,16 @@
+#
+# Copyright 2009 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.
+#
+
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:3099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

Copied: trunk/examples/jms/clustered-static-discovery/server2/hornetq-beans.xml (from rev 10019, trunk/examples/jms/clustered-static-discovery/server1/hornetq-beans.xml)
===================================================================
--- trunk/examples/jms/clustered-static-discovery/server2/hornetq-beans.xml	                        (rev 0)
+++ trunk/examples/jms/clustered-static-discovery/server2/hornetq-beans.xml	2010-12-09 16:47:56 UTC (rev 10021)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Copyright 2009 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.
+  -->
+
+<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">3099</property>
+      <property name="bindAddress">localhost</property>
+      <property name="rmiPort">3098</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>

Copied: trunk/examples/jms/clustered-static-discovery/server2/hornetq-configuration.xml (from rev 10019, trunk/examples/jms/clustered-static-discovery/server1/hornetq-configuration.xml)
===================================================================
--- trunk/examples/jms/clustered-static-discovery/server2/hornetq-configuration.xml	                        (rev 0)
+++ trunk/examples/jms/clustered-static-discovery/server2/hornetq-configuration.xml	2010-12-09 16:47:56 UTC (rev 10021)
@@ -0,0 +1,69 @@
+<!--
+  ~ Copyright 2009 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.
+  -->
+
+<configuration xmlns="urn:hornetq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
+   <clustered>true</clustered>
+
+   <!-- Connectors -->
+   <connectors>
+      <connector name="netty-connector">
+         <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+         <param key="port" value="5447"/>
+      </connector>
+      <!-- connector to the server0 -->
+      <connector name="server0-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="5447"/>
+      </acceptor>
+   </acceptors>
+   
+   <!-- Clustering configuration -->
+   <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>
+         <static-connectors>
+            <connector-ref>server0-connector</connector-ref>
+         </static-connectors>
+      </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>

Copied: trunk/examples/jms/clustered-static-discovery/server2/hornetq-jms.xml (from rev 10019, trunk/examples/jms/clustered-static-discovery/server1/hornetq-jms.xml)
===================================================================
--- trunk/examples/jms/clustered-static-discovery/server2/hornetq-jms.xml	                        (rev 0)
+++ trunk/examples/jms/clustered-static-discovery/server2/hornetq-jms.xml	2010-12-09 16:47:56 UTC (rev 10021)
@@ -0,0 +1,45 @@
+<!--
+  ~ Copyright 2009 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.
+  -->
+
+<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>
+
+       <ha>true</ha>
+      <!-- Pause 1 second between connect attempts -->
+      <retry-interval>1000</retry-interval>
+
+      <!-- Multiply subsequent reconnect pauses by this multiplier. This can be used to
+      implement an exponential back-off. For our purposes we just set to 1.0 so each reconnect
+      pause is the same length -->
+      <retry-interval-multiplier>1.0</retry-interval-multiplier>
+
+      <!-- Try reconnecting an unlimited number of times (-1 means "unlimited") -->
+      <reconnect-attempts>-1</reconnect-attempts>
+       
+   </connection-factory>
+
+   <!--the queue used by the example-->
+   <queue name="exampleQueue">
+      <entry name="/queue/exampleQueue"/>
+   </queue>
+
+</configuration>
\ No newline at end of file

Copied: trunk/examples/jms/clustered-static-discovery/server2/hornetq-users.xml (from rev 10019, trunk/examples/jms/clustered-static-discovery/server1/hornetq-users.xml)
===================================================================
--- trunk/examples/jms/clustered-static-discovery/server2/hornetq-users.xml	                        (rev 0)
+++ trunk/examples/jms/clustered-static-discovery/server2/hornetq-users.xml	2010-12-09 16:47:56 UTC (rev 10021)
@@ -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

Copied: trunk/examples/jms/clustered-static-discovery/server2/jndi.properties (from rev 10019, trunk/examples/jms/clustered-static-discovery/server1/jndi.properties)
===================================================================
--- trunk/examples/jms/clustered-static-discovery/server2/jndi.properties	                        (rev 0)
+++ trunk/examples/jms/clustered-static-discovery/server2/jndi.properties	2010-12-09 16:47:56 UTC (rev 10021)
@@ -0,0 +1,15 @@
+#
+# Copyright 2009 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.
+#
+
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
\ No newline at end of file

Copied: trunk/examples/jms/clustered-static-discovery/server3/client-jndi.properties (from rev 10019, trunk/examples/jms/clustered-static-discovery/server1/client-jndi.properties)
===================================================================
--- trunk/examples/jms/clustered-static-discovery/server3/client-jndi.properties	                        (rev 0)
+++ trunk/examples/jms/clustered-static-discovery/server3/client-jndi.properties	2010-12-09 16:47:56 UTC (rev 10021)
@@ -0,0 +1,16 @@
+#
+# Copyright 2009 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.
+#
+
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:4099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

Copied: trunk/examples/jms/clustered-static-discovery/server3/hornetq-beans.xml (from rev 10019, trunk/examples/jms/clustered-static-discovery/server1/hornetq-beans.xml)
===================================================================
--- trunk/examples/jms/clustered-static-discovery/server3/hornetq-beans.xml	                        (rev 0)
+++ trunk/examples/jms/clustered-static-discovery/server3/hornetq-beans.xml	2010-12-09 16:47:56 UTC (rev 10021)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Copyright 2009 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.
+  -->
+
+<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">4099</property>
+      <property name="bindAddress">localhost</property>
+      <property name="rmiPort">4098</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>

Copied: trunk/examples/jms/clustered-static-discovery/server3/hornetq-configuration.xml (from rev 10019, trunk/examples/jms/clustered-static-discovery/server1/hornetq-configuration.xml)
===================================================================
--- trunk/examples/jms/clustered-static-discovery/server3/hornetq-configuration.xml	                        (rev 0)
+++ trunk/examples/jms/clustered-static-discovery/server3/hornetq-configuration.xml	2010-12-09 16:47:56 UTC (rev 10021)
@@ -0,0 +1,69 @@
+<!--
+  ~ Copyright 2009 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.
+  -->
+
+<configuration xmlns="urn:hornetq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
+   <clustered>true</clustered>
+
+   <!-- Connectors -->
+   <connectors>
+      <connector name="netty-connector">
+         <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+         <param key="port" value="5448"/>
+      </connector>
+      <!-- connector to the server0 -->
+      <connector name="server0-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="5448"/>
+      </acceptor>
+   </acceptors>
+   
+   <!-- Clustering configuration -->
+   <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>
+         <static-connectors allow-direct-connections-only="false">
+            <connector-ref>server0-connector</connector-ref>
+         </static-connectors>
+      </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>

Copied: trunk/examples/jms/clustered-static-discovery/server3/hornetq-jms.xml (from rev 10019, trunk/examples/jms/clustered-static-discovery/server1/hornetq-jms.xml)
===================================================================
--- trunk/examples/jms/clustered-static-discovery/server3/hornetq-jms.xml	                        (rev 0)
+++ trunk/examples/jms/clustered-static-discovery/server3/hornetq-jms.xml	2010-12-09 16:47:56 UTC (rev 10021)
@@ -0,0 +1,45 @@
+<!--
+  ~ Copyright 2009 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.
+  -->
+
+<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>
+
+       <ha>true</ha>
+      <!-- Pause 1 second between connect attempts -->
+      <retry-interval>1000</retry-interval>
+
+      <!-- Multiply subsequent reconnect pauses by this multiplier. This can be used to
+      implement an exponential back-off. For our purposes we just set to 1.0 so each reconnect
+      pause is the same length -->
+      <retry-interval-multiplier>1.0</retry-interval-multiplier>
+
+      <!-- Try reconnecting an unlimited number of times (-1 means "unlimited") -->
+      <reconnect-attempts>-1</reconnect-attempts>
+       
+   </connection-factory>
+
+   <!--the queue used by the example-->
+   <queue name="exampleQueue">
+      <entry name="/queue/exampleQueue"/>
+   </queue>
+
+</configuration>
\ No newline at end of file

Copied: trunk/examples/jms/clustered-static-discovery/server3/hornetq-users.xml (from rev 10019, trunk/examples/jms/clustered-static-discovery/server1/hornetq-users.xml)
===================================================================
--- trunk/examples/jms/clustered-static-discovery/server3/hornetq-users.xml	                        (rev 0)
+++ trunk/examples/jms/clustered-static-discovery/server3/hornetq-users.xml	2010-12-09 16:47:56 UTC (rev 10021)
@@ -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

Copied: trunk/examples/jms/clustered-static-discovery/server3/jndi.properties (from rev 10019, trunk/examples/jms/clustered-static-discovery/server1/jndi.properties)
===================================================================
--- trunk/examples/jms/clustered-static-discovery/server3/jndi.properties	                        (rev 0)
+++ trunk/examples/jms/clustered-static-discovery/server3/jndi.properties	2010-12-09 16:47:56 UTC (rev 10021)
@@ -0,0 +1,2 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
\ No newline at end of file

Modified: trunk/examples/jms/clustered-static-discovery/src/org/hornetq/jms/example/StaticClusteredQueueExample.java
===================================================================
--- trunk/examples/jms/clustered-static-discovery/src/org/hornetq/jms/example/StaticClusteredQueueExample.java	2010-12-09 15:01:09 UTC (rev 10020)
+++ trunk/examples/jms/clustered-static-discovery/src/org/hornetq/jms/example/StaticClusteredQueueExample.java	2010-12-09 16:47:56 UTC (rev 10021)
@@ -39,18 +39,22 @@
    @Override
    public boolean runExample() throws Exception
    {
+      Connection initialConnection = null;
+
       Connection connection0 = null;
 
       Connection connection1 = null;
 
+      Connection connection2 = null;
+
+      Connection connection3 = null;
+
       InitialContext ic0 = null;
 
-      InitialContext ic1 = null;
-
       try
       {
          // Step 1. Get an initial context for looking up JNDI from server 0
-         ic0 = getContext(0);
+         ic0 = getContext(3);
 
          // Step 2. Look-up the JMS Queue object from JNDI
          Queue queue = (Queue)ic0.lookup("/queue/exampleQueue");
@@ -58,42 +62,62 @@
          // 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);
+         //grab an initial connection and wait, in reality you wouldn't do it this way but since we want to ensure an
+         // equal load balance we do this and then create 4 connections round robined
+         initialConnection = cf0.createConnection();
 
-         // Step 5. Look-up a JMS Connection Factory object from JNDI on server 1
-         ConnectionFactory cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
-
+         Thread.sleep(2000);
          // 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();
+         connection1 = cf0.createConnection();
 
+         // Step 6. We create a JMS Connection connection0 which is a connection to server 0
+         connection2 = cf0.createConnection();
+
+         // Step 7. We create a JMS Connection connection1 which is a connection to server 1
+         connection3 = cf0.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 8. We create a JMS Session on server 0
+         Session session2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         // Step 9. We create a JMS Session on server 1
+         Session session3 = connection3.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
          // Step 10. We start the connections to ensure delivery occurs on them
          connection0.start();
 
          connection1.start();
 
+         connection2.start();
+
+         connection3.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);
+         MessageConsumer consumer2 = session2.createConsumer(queue);
 
-         // Step 12. We create a JMS MessageProducer object on server 0
-         MessageProducer producer = session0.createProducer(queue);
+         MessageConsumer consumer3 = session3.createConsumer(queue);
 
+         Thread.sleep(2000);
+
+         // Step 12. We create a JMS MessageProducer object on server 3
+         MessageProducer producer = session3.createProducer(queue);
+
          // Step 13. We send some messages to server 0
 
-         final int numMessages = 10;
+         final int numMessages = 20;
 
          for (int i = 0; i < numMessages; i++)
          {
@@ -103,21 +127,37 @@
 
             System.out.println("Sent message: " + message.getText());
          }
-
+         Thread.sleep(2000);
          // 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
+         int con0Node = getServer(connection0);
+         int con1Node = getServer(connection1);
+         int con2Node = getServer(connection2);
+         int con3Node = getServer(connection3);
 
-         for (int i = 0; i < numMessages; i += 2)
+         if(con0Node + con1Node + con2Node + con3Node != 6)
          {
+            return false;
+         }
+         for (int i = 0; i < numMessages; i += 4)
+         {
             TextMessage message0 = (TextMessage)consumer0.receive(5000);
 
-            System.out.println("Got message: " + message0.getText() + " from node 0");
+            System.out.println("Got message: " + message0.getText() + " from node " + con0Node);
 
             TextMessage message1 = (TextMessage)consumer1.receive(5000);
 
-            System.out.println("Got message: " + message1.getText() + " from node 1");
+            System.out.println("Got message: " + message1.getText() + " from node " + con1Node);
+
+            TextMessage message2 = (TextMessage)consumer2.receive(5000);
+
+            System.out.println("Got message: " + message2.getText() + " from node " + con2Node);
+
+            TextMessage message3 = (TextMessage)consumer3.receive(5000);
+
+            System.out.println("Got message: " + message3.getText() + " from node " + con3Node);
          }
 
          return true;
@@ -126,6 +166,11 @@
       {
          // Step 15. Be sure to close our resources!
 
+         if (initialConnection != null)
+         {
+            initialConnection.close();
+         }
+
          if (connection0 != null)
          {
             connection0.close();
@@ -136,15 +181,20 @@
             connection1.close();
          }
 
-         if (ic0 != null)
+         if (connection2 != null)
          {
-            ic0.close();
+            connection2.close();
          }
 
-         if (ic1 != null)
+         if (connection3 != null)
          {
-            ic1.close();
+            connection3.close();
          }
+
+         if (ic0 != null)
+         {
+            ic0.close();
+         }
       }
    }
 



More information about the hornetq-commits mailing list