[jboss-cvs] JBoss Messaging SVN: r6345 - in trunk/examples/jms: clustered-durable-subscription and 20 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Apr 7 12:52:42 EDT 2009


Author: timfox
Date: 2009-04-07 12:52:42 -0400 (Tue, 07 Apr 2009)
New Revision: 6345

Added:
   trunk/examples/jms/clustered-durable-subscription/
   trunk/examples/jms/clustered-durable-subscription/build/
   trunk/examples/jms/clustered-durable-subscription/build/classes/
   trunk/examples/jms/clustered-durable-subscription/build/classes/org/
   trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/
   trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/
   trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/
   trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/ClusteredDurableSubscriptionExample.class
   trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/JMSExample.class
   trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/SpawnedJMSServer.class
   trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/SpawnedVMSupport$ProcessLogger.class
   trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/SpawnedVMSupport.class
   trunk/examples/jms/clustered-durable-subscription/logs/
   trunk/examples/jms/clustered-durable-subscription/logs/messaging.log
   trunk/examples/jms/clustered-durable-subscription/readme.html
   trunk/examples/jms/clustered-durable-subscription/server0/
   trunk/examples/jms/clustered-durable-subscription/server0/client-jndi.properties
   trunk/examples/jms/clustered-durable-subscription/server0/data/
   trunk/examples/jms/clustered-durable-subscription/server0/data/bindings/
   trunk/examples/jms/clustered-durable-subscription/server0/data/bindings/jbm-bindings-1.bindings
   trunk/examples/jms/clustered-durable-subscription/server0/data/bindings/jbm-bindings-2.bindings
   trunk/examples/jms/clustered-durable-subscription/server0/data/journal/
   trunk/examples/jms/clustered-durable-subscription/server0/data/journal/jbm-data-1.jbm
   trunk/examples/jms/clustered-durable-subscription/server0/data/journal/jbm-data-2.jbm
   trunk/examples/jms/clustered-durable-subscription/server0/data/largemessages/
   trunk/examples/jms/clustered-durable-subscription/server0/jbm-configuration.xml
   trunk/examples/jms/clustered-durable-subscription/server0/jbm-jms.xml
   trunk/examples/jms/clustered-durable-subscription/server0/jbm-queues.xml
   trunk/examples/jms/clustered-durable-subscription/server0/jbm-security.xml
   trunk/examples/jms/clustered-durable-subscription/server0/jbm-standalone-beans.xml
   trunk/examples/jms/clustered-durable-subscription/server0/logs/
   trunk/examples/jms/clustered-durable-subscription/server0/logs/messaging.log
   trunk/examples/jms/clustered-durable-subscription/src/
   trunk/examples/jms/clustered-durable-subscription/src/org/
   trunk/examples/jms/clustered-durable-subscription/src/org/jboss/
   trunk/examples/jms/clustered-durable-subscription/src/org/jboss/jms/
   trunk/examples/jms/clustered-durable-subscription/src/org/jboss/jms/example/
   trunk/examples/jms/clustered-durable-subscription/src/org/jboss/jms/example/ClusteredDurableSubscriptionExample.java
Modified:
   trunk/examples/jms/clustered-queue/build.xml
   trunk/examples/jms/clustered-queue/src/org/jboss/jms/example/ClusteredQueueExample.java
   trunk/examples/jms/clustered-topic/readme.html
Log:
added clustered durable sub example

Added: trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/ClusteredDurableSubscriptionExample.class
===================================================================
(Binary files differ)


Property changes on: trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/ClusteredDurableSubscriptionExample.class
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/JMSExample.class
===================================================================
(Binary files differ)


Property changes on: trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/JMSExample.class
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/SpawnedJMSServer.class
===================================================================
(Binary files differ)


Property changes on: trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/SpawnedJMSServer.class
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/SpawnedVMSupport$ProcessLogger.class
===================================================================
(Binary files differ)


Property changes on: trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/SpawnedVMSupport$ProcessLogger.class
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/SpawnedVMSupport.class
===================================================================
(Binary files differ)


Property changes on: trunk/examples/jms/clustered-durable-subscription/build/classes/org/jboss/jms/example/SpawnedVMSupport.class
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/examples/jms/clustered-durable-subscription/logs/messaging.log
===================================================================
--- trunk/examples/jms/clustered-durable-subscription/logs/messaging.log	                        (rev 0)
+++ trunk/examples/jms/clustered-durable-subscription/logs/messaging.log	2009-04-07 16:52:42 UTC (rev 6345)
@@ -0,0 +1,5 @@
+2009-04-07 17:41:22,578 0     INFO  [org.jboss.jms.example.JMSExample] (main:) jbm.example.runServer is true
+2009-04-07 17:41:22,579 1     INFO  [org.jboss.jms.example.JMSExample] (main:) starting server with config 'server0' logServerOutput true
+2009-04-07 17:41:28,043 5465  INFO  [org.jboss.jms.example.JMSExample] (main:) starting server with config 'server1' logServerOutput true
+2009-04-07 17:41:32,643 10065 INFO  [org.jboss.jms.example.JMSExample] (main:) using server0/client-jndi.properties for jndi
+2009-04-07 17:41:32,952 10374 INFO  [org.jboss.jms.example.JMSExample] (main:) using server1/client-jndi.properties for jndi

Added: trunk/examples/jms/clustered-durable-subscription/readme.html
===================================================================
--- trunk/examples/jms/clustered-durable-subscription/readme.html	                        (rev 0)
+++ trunk/examples/jms/clustered-durable-subscription/readme.html	2009-04-07 16:52:42 UTC (rev 6345)
@@ -0,0 +1,192 @@
+<html>
+  <head>
+    <title>JBoss Messaging JMS Durable Subscription Example</title>
+    <link rel="stylesheet" type="text/css" href="../common/common.css">
+  </head>
+  <body>
+     <h1>JBoss Messaging JMS Durable Subscription Example</h1>
+     <br>
+     <p>This example demonstrates a clustered JMS durable subscription.
+     Normally durable subscriptions exist on a single node and can only have one subscriber at any one time,
+     however, with JBM 2.0 it's possible to create durable subscription instances with the same name and client-id
+     on different nodes of the cluster, and consume from them simultaneously.
+     This allows the work of processing messages from a durable subscription to be spread across the cluster in
+     a similar way to how JMS Queues can be load balanced across the cluster
+     </p>     
+     <p>In this example we first configure the two nodes to form a cluster, then we then create a durable subscriber 
+     with the same name and client-id on both nodes, 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 the messages are round robin'd between
+     the two subscription instances. Note that each durable subscription instance with the same name and client-id 
+     <b>does not</b> receive its own copy of the messages. This is because the instances on different nodes form a
+     single "logical" durable subscription, in the same way multiple JMS Queue instances on different nodes
+     form a single "local" JMS Queue</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>Here's the relevant snippet from the server configuration, which tells the server to form a cluster between the two nodes
+     and to load balance the messages between the nodes.</p>     
+     <pre>
+     <code>
+   &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;
+   </code>
+     </pre>    
+     <p>For more information on JBoss Messaging load balancing, and 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>ant</code> from this directory</i></p>
+     <br>
+     <ol>
+        <li> Get an initial context for looking up JNDI from server 0.</li>
+        <pre>
+           <code>
+   ic0 = getContext(0);
+   </code>
+        </pre>
+
+        <li>Look-up the JMS Topic object from JNDI</li>
+        <pre>
+           <code>Topic topic = (Topic)ic0.lookup("/topic/exampleTopic");</code>
+        </pre>
+
+        <li>Look-up a JMS Connection Factory object from JNDI on server 0</li>
+        <pre>
+           <code>ConnectionFactory cf0 = (ConnectionFactory)ic0.lookup("/ConnectionFactory");</code>
+        </pre>
+
+        <li>Get an initial context for looking up JNDI from server 1.</li>
+        <pre>
+           <code>ic1 = getContext(1);</code>
+        </pre>
+
+        <li>Look-up a JMS Connection Factory object from JNDI on server 1</li>
+        <pre>
+           <code>ConnectionFactory cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
+           </code>
+        </pre>
+
+        <li>We create a JMS Connection connection0 which is a connection to server 0
+        and set the same client-id.</li>
+        <pre>
+          <code>
+   connection0 = cf0.createConnection();
+   final String clientID = "my-client-id";         
+   connection0.setClientID(clientID);
+          </code>
+        </pre>
+        
+        <li>We create a JMS Connection connection1 which is a connection to server 1
+        and set the same client-id.</li>
+        <pre>
+          <code>
+   connection1 = cf1.createConnection();
+   connection1.setClientID(clientID);
+          </code>
+        </pre>
+
+        <li>We create a JMS Session on server 0</li>
+        <pre>
+           <code>
+   Session session0 = connection0.createSession(false, Session.AUTO_ACKNOWLEDGE);
+           </code>
+        </pre>
+        
+        <li>We create a JMS Session on server 1</li>
+        <pre>
+           <code>
+   Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            </code>
+        </pre>
+
+        <li>We start the connections to ensure delivery occurs on them</li>
+        <pre>
+           <code>
+   connection0.start();
+
+   connection1.start();
+           </code>
+        </pre>
+
+        <li>We create JMS durable subscriptions with the same name and client-id on both nodes
+        of the cluster
+        </li>
+        <pre>
+           <code>
+   final String subscriptionName = "my-subscription";
+         
+   MessageConsumer subscriber0 = session0.createDurableSubscriber(topic, subscriptionName);
+
+   MessageConsumer subscriber1 = session1.createDurableSubscriber(topic, subscriptionName);
+           </code>
+        </pre>
+
+        <li>We create a JMS MessageProducer object on server 0.</li>
+        <pre>
+           <code>
+   MessageProducer producer = session0.createProducer(topic);</code>
+        </pre>
+
+        <li>We send some messages to server 0.</li>
+        <pre>
+           <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.
+        Note that the messages have been load-balanced between the two nodes, with some
+        messages on node 0 and others on node 1.
+        The "logical" subscription is distributed across the cluster an contains exactly one copy of all the messages sent.
+         </li>
+        <pre>
+           <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>
+           <code>
+	finally
+	{
+	   if (connection0 != null)
+	   {
+	      connection0.close();
+	   }
+	      
+	   if (connection1 != null)
+	   {
+	      connection1.close();
+	   }
+	}
+           </code>
+        </pre>
+
+     </ol>
+  </body>
+</html>
\ No newline at end of file

Added: trunk/examples/jms/clustered-durable-subscription/server0/client-jndi.properties
===================================================================
--- trunk/examples/jms/clustered-durable-subscription/server0/client-jndi.properties	                        (rev 0)
+++ trunk/examples/jms/clustered-durable-subscription/server0/client-jndi.properties	2009-04-07 16:52:42 UTC (rev 6345)
@@ -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

Added: trunk/examples/jms/clustered-durable-subscription/server0/data/bindings/jbm-bindings-1.bindings
===================================================================
(Binary files differ)


Property changes on: trunk/examples/jms/clustered-durable-subscription/server0/data/bindings/jbm-bindings-1.bindings
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/examples/jms/clustered-durable-subscription/server0/data/bindings/jbm-bindings-2.bindings
===================================================================
(Binary files differ)


Property changes on: trunk/examples/jms/clustered-durable-subscription/server0/data/bindings/jbm-bindings-2.bindings
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/examples/jms/clustered-durable-subscription/server0/data/journal/jbm-data-1.jbm
===================================================================
(Binary files differ)


Property changes on: trunk/examples/jms/clustered-durable-subscription/server0/data/journal/jbm-data-1.jbm
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/examples/jms/clustered-durable-subscription/server0/data/journal/jbm-data-2.jbm
===================================================================
(Binary files differ)


Property changes on: trunk/examples/jms/clustered-durable-subscription/server0/data/journal/jbm-data-2.jbm
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/examples/jms/clustered-durable-subscription/server0/jbm-configuration.xml
===================================================================
--- trunk/examples/jms/clustered-durable-subscription/server0/jbm-configuration.xml	                        (rev 0)
+++ trunk/examples/jms/clustered-durable-subscription/server0/jbm-configuration.xml	2009-04-07 16:52:42 UTC (rev 6345)
@@ -0,0 +1,54 @@
+<deployment xmlns="urn:jboss:messaging"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-configuration.xsd">
+   <configuration>
+
+      <clustered>true</clustered>
+
+      <!-- Connectors -->
+
+      <connector name="netty-connector">
+         <factory-class>org.jboss.messaging.integration.transports.netty.NettyConnectorFactory</factory-class>
+         <param key="jbm.remoting.netty.port" value="5445" type="Integer"/>
+      </connector>
+
+      <!-- Acceptors -->
+
+      <acceptor name="netty-acceptor">
+         <factory-class>org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory</factory-class>
+         <param key="jbm.remoting.netty.port" value="5445" type="Integer"/>
+      </acceptor>
+
+      <!-- Clustering configuration -->
+
+      <!-- Clustering configuration -->
+
+      <broadcast-group name="my-broadcast-group">
+         <group-address>231.7.7.7</group-address>
+         <group-port>9876</group-port>
+         <broadcast-period>100</broadcast-period>
+         <connector-ref connector-name="netty-connector"/>
+      </broadcast-group>
+
+      <discovery-group name="my-discovery-group">
+         <group-address>231.7.7.7</group-address>
+         <group-port>9876</group-port>
+         <refresh-timeout>10000</refresh-timeout>
+      </discovery-group>
+
+      <cluster-connection name="my-cluster">
+         <address>jms</address>
+         <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>
+
+      <!--  other configuration -->
+
+      <journal-min-files>2</journal-min-files>
+
+   </configuration>
+
+</deployment>

Added: trunk/examples/jms/clustered-durable-subscription/server0/jbm-jms.xml
===================================================================
--- trunk/examples/jms/clustered-durable-subscription/server0/jbm-jms.xml	                        (rev 0)
+++ trunk/examples/jms/clustered-durable-subscription/server0/jbm-jms.xml	2009-04-07 16:52:42 UTC (rev 6345)
@@ -0,0 +1,18 @@
+<deployment xmlns="urn:jboss:messaging"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-jms.xsd ">
+   <!--the connection factory used by the example-->
+   <connection-factory name="ConnectionFactory">
+      <connector-ref connector-name="netty-connector"/>
+      <entry name="ConnectionFactory"/>
+      <entry name="XAConnectionFactory"/>
+      <entry name="java:/ConnectionFactory"/>
+      <entry name="java:/XAConnectionFactory"/>
+   </connection-factory>
+
+   <!--the topic used by the example-->
+   <topic name="exampleTopic">
+      <entry name="/topic/exampleTopic"/>
+   </topic>
+
+</deployment>
\ No newline at end of file

Added: trunk/examples/jms/clustered-durable-subscription/server0/jbm-queues.xml
===================================================================
--- trunk/examples/jms/clustered-durable-subscription/server0/jbm-queues.xml	                        (rev 0)
+++ trunk/examples/jms/clustered-durable-subscription/server0/jbm-queues.xml	2009-04-07 16:52:42 UTC (rev 6345)
@@ -0,0 +1,15 @@
+<settings xmlns="urn:jboss:messaging"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-queues.xsd ">
+
+   <!--security for example queue-->
+   <security match="jms.topic.exampleTopic">
+      <permission type="createDurableQueue" roles="guest"/>
+      <permission type="deleteDurableQueue" roles="guest"/>
+      <permission type="createTempQueue" roles="guest"/>
+      <permission type="deleteTempQueue" roles="guest"/>
+      <permission type="consume" roles="guest"/>
+      <permission type="send" roles="guest"/>
+   </security>
+
+</settings>

Added: trunk/examples/jms/clustered-durable-subscription/server0/jbm-security.xml
===================================================================
--- trunk/examples/jms/clustered-durable-subscription/server0/jbm-security.xml	                        (rev 0)
+++ trunk/examples/jms/clustered-durable-subscription/server0/jbm-security.xml	2009-04-07 16:52:42 UTC (rev 6345)
@@ -0,0 +1,7 @@
+<deployment xmlns="urn:jboss:messaging" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-security.xsd ">
+   <!-- the default user.  this is used where username is null-->
+   <defaultuser name="guest" password="guest">
+      <role name="guest"/>
+   </defaultuser>
+</deployment>
\ No newline at end of file

Added: trunk/examples/jms/clustered-durable-subscription/server0/jbm-standalone-beans.xml
===================================================================
--- trunk/examples/jms/clustered-durable-subscription/server0/jbm-standalone-beans.xml	                        (rev 0)
+++ trunk/examples/jms/clustered-durable-subscription/server0/jbm-standalone-beans.xml	2009-04-07 16:52:42 UTC (rev 6345)
@@ -0,0 +1,174 @@
+<?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>
+
+   <bean name="DeploymentManager" class="org.jboss.messaging.core.deployers.impl.FileDeploymentManager">
+      <constructor>
+         <!-- The scan time in milliseconds -->
+         <parameter>5000</parameter>
+      </constructor>
+   </bean>
+   
+   <bean name="Configuration" class="org.jboss.messaging.core.config.impl.FileConfiguration"/>
+
+   <!--<bean name="JBMSecurityManager" class="org.jboss.messaging.core.security.impl.JBossASSecurityManager"/>-->
+
+   <bean name="JBMSecurityManager" class="org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl">
+   </bean>
+
+   <bean name="BasicSecurityDeployer" class="org.jboss.messaging.core.deployers.impl.BasicSecurityDeployer">
+      <constructor>
+         <parameter>
+            <inject bean="DeploymentManager"/>
+         </parameter>
+      </constructor>
+      <property name="jbmSecurityManager">
+         <inject bean="JBMSecurityManager"/>
+      </property>
+   </bean>
+
+   <bean name="MessagingServer" class="org.jboss.messaging.core.server.impl.MessagingServerImpl">
+      <depends>AddressSettingsDeployer</depends>
+      <depends>QueueDeployer</depends>
+      
+      <property name="storageManager">
+         <inject bean="StorageManager"/>
+      </property>
+      <property name="remotingService">
+         <inject bean="RemotingService"/>
+      </property>
+      <property name="configuration">
+         <inject bean="Configuration"/>
+      </property>
+      <property name="securityManager">
+         <inject bean="JBMSecurityManager"/>
+      </property>
+      <property name="managementService">
+         <inject bean="ManagementService"/>
+      </property>      
+   </bean>
+
+   <bean name="StorageManager" class="org.jboss.messaging.core.persistence.impl.journal.JournalStorageManager">
+      <constructor>
+         <parameter>
+            <inject bean="Configuration"/>
+         </parameter>
+      </constructor>
+   </bean>
+
+   <bean name="RemotingService" class="org.jboss.messaging.core.remoting.server.impl.RemotingServiceImpl">
+      <constructor>
+         <parameter>
+            <inject bean="Configuration"/>
+         </parameter>
+      </constructor>
+      <property name="managementService">
+         <inject bean="ManagementService"/>
+      </property>
+   </bean>
+   
+   <bean name="JMSServerManager" class="org.jboss.messaging.jms.server.impl.JMSServerManagerImpl">
+      <constructor>
+         <parameter>
+            <inject bean="MessagingServer" property="serverManagement"/>
+         </parameter>
+         <parameter>
+            <inject bean="MessagingServer" property="postOffice"/>
+         </parameter>
+         <parameter>
+            <inject bean="MessagingServer" property="storageManager"/>
+         </parameter>
+         <parameter>
+            <inject bean="MessagingServer" property="addressSettingsRepository"/>
+         </parameter>
+         <parameter>
+            <inject bean="JMSManagementService"/>
+         </parameter>
+      </constructor>
+   </bean>
+
+   <bean name="JMSServerDeployer" class="org.jboss.messaging.jms.server.impl.JMSServerDeployer">
+      <constructor>
+         <parameter>
+            <inject bean="DeploymentManager"/>
+         </parameter>
+          <parameter>
+            <inject bean="Configuration"/>
+         </parameter>
+      </constructor>
+      <property name="jmsServerManager">
+         <inject bean="JMSServerManager"/>
+      </property>
+   </bean>
+
+   <bean name="AddressSettingsDeployer" class="org.jboss.messaging.core.deployers.impl.AddressSettingsDeployer">
+      <constructor>
+         <parameter>
+            <inject bean="DeploymentManager"/>
+         </parameter>
+         <parameter>
+            <inject bean="MessagingServer" property="addressSettingsRepository" state="Configured"/>
+         </parameter>
+      </constructor>
+   </bean>
+
+   <bean name="QueueDeployer" class="org.jboss.messaging.core.deployers.impl.QueueDeployer">
+      <constructor>
+         <parameter>
+            <inject bean="DeploymentManager"/>
+         </parameter>
+         <parameter>
+            <inject bean="Configuration"/>
+         </parameter>
+      </constructor>
+   </bean>
+   
+   <bean name="SecurityDeployer" class="org.jboss.messaging.core.deployers.impl.SecurityDeployer">
+      <constructor>
+         <parameter>
+            <inject bean="DeploymentManager"/>
+         </parameter>
+         <parameter>
+            <inject bean="MessagingServer" property="securityRepository"/>
+         </parameter>
+      </constructor>
+   </bean>
+
+   <bean name="ManagementService" class="org.jboss.messaging.core.management.impl.ManagementServiceImpl">
+      <constructor>
+         <parameter>
+            <inject bean="MBeanServer"/>
+         </parameter>
+         <parameter>
+            <inject bean="Configuration" property="JMXManagementEnabled" />
+         </parameter>
+      </constructor>
+   </bean>
+   
+   <bean name="JMSManagementService" class="org.jboss.messaging.jms.server.management.impl.JMSManagementServiceImpl">
+      <constructor>
+         <parameter>
+            <inject bean="ManagementService"/>
+         </parameter>
+      </constructor>
+   </bean>
+   
+   <bean name="MBeanServer" class="javax.management.MBeanServer">
+      <constructor factoryClass="java.lang.management.ManagementFactory"
+                   factoryMethod="getPlatformMBeanServer"/>
+   </bean> 
+   
+</deployment>

Added: trunk/examples/jms/clustered-durable-subscription/server0/logs/messaging.log
===================================================================
--- trunk/examples/jms/clustered-durable-subscription/server0/logs/messaging.log	                        (rev 0)
+++ trunk/examples/jms/clustered-durable-subscription/server0/logs/messaging.log	2009-04-07 16:52:42 UTC (rev 6345)
@@ -0,0 +1,12 @@
+2009-04-07 17:41:25,259 1135  INFO  [org.jboss.messaging.core.deployers.impl.XmlDeployer] (main:) deploying guest
+2009-04-07 17:41:25,491 1367  INFO  [org.jboss.messaging.core.persistence.impl.journal.JournalStorageManager] (main:) AIO journal selected
+2009-04-07 17:41:25,494 1370  WARN  [org.jboss.messaging.core.persistence.impl.journal.JournalStorageManager] (main:) AIO wasn't located on this platform, it will fall back to using pure Java NIO. If your platform is Linux, install LibAIO to enable the AIO journal
+2009-04-07 17:41:26,397 2273  WARN  [org.jboss.messaging.core.security.impl.SecurityStoreImpl] (main:) It has been detected that the cluster admin password which is used to replicate management operation from one node to the other has not had its password changed from the installation default. Please see the JBoss Messaging user guide for instructions on how to do this.
+2009-04-07 17:41:27,917 3793  INFO  [org.jboss.messaging.core.deployers.impl.XmlDeployer] (main:) deploying jms.topic.exampleTopic
+2009-04-07 17:41:27,971 3847  INFO  [org.jboss.messaging.core.deployers.impl.XmlDeployer] (main:) deploying exampleTopic
+2009-04-07 17:41:27,997 3873  INFO  [org.jboss.messaging.core.deployers.impl.XmlDeployer] (main:) deploying ConnectionFactory
+2009-04-07 17:41:28,037 3913  WARN  [org.jboss.messaging.jms.server.impl.JMSServerManagerImpl] (main:) Binding for java:/ConnectionFactory already exists
+2009-04-07 17:41:28,038 3914  WARN  [org.jboss.messaging.jms.server.impl.JMSServerManagerImpl] (main:) Binding for java:/XAConnectionFactory already exists
+2009-04-07 17:41:28,042 3918  INFO  [org.jboss.messaging.integration.bootstrap.JBMBootstrapServer] (main:) JBM Server Started
+2009-04-07 17:41:32,465 8341  WARN  [org.jboss.messaging.core.security.impl.SecurityStoreImpl] (New I/O server worker #1-1:) It has been detected that the cluster admin password which is used to replicate management operation from one node to the other has not had its password changed from the installation default. Please see the JBoss Messaging user guide for instructions on how to do this.
+2009-04-07 17:41:34,797 10673 INFO  [org.jboss.messaging.integration.bootstrap.JBMBootstrapServer] (Thread-1:) Shutting down

Added: trunk/examples/jms/clustered-durable-subscription/src/org/jboss/jms/example/ClusteredDurableSubscriptionExample.java
===================================================================
--- trunk/examples/jms/clustered-durable-subscription/src/org/jboss/jms/example/ClusteredDurableSubscriptionExample.java	                        (rev 0)
+++ trunk/examples/jms/clustered-durable-subscription/src/org/jboss/jms/example/ClusteredDurableSubscriptionExample.java	2009-04-07 16:52:42 UTC (rev 6345)
@@ -0,0 +1,169 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+   * by the @authors tag. See the copyright.txt in the distribution for a
+   * full listing of individual contributors.
+   *
+   * This is free software; you can redistribute it and/or modify it
+   * under the terms of the GNU Lesser General Public License as
+   * published by the Free Software Foundation; either version 2.1 of
+   * the License, or (at your option) any later version.
+   *
+   * This software is distributed in the hope that it will be useful,
+   * but WITHOUT ANY WARRANTY; without even the implied warranty of
+   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   * Lesser General Public License for more details.
+   *
+   * You should have received a copy of the GNU Lesser General Public
+   * License along with this software; if not, write to the Free
+   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+   */
+package org.jboss.jms.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+import javax.naming.InitialContext;
+
+/**
+ * A simple example that shows a JMS Durable Subscription across two nodes of a cluster.
+ * 
+ * The same durable subscription can exist on more than one node of the cluster, and messages
+ * sent to the topic will be load-balanced in a round-robin fashion between the two nodes
+ *
+ */
+public class ClusteredDurableSubscriptionExample extends JMSExample
+{
+   public static void main(String[] args)
+   {
+      new ClusteredDurableSubscriptionExample().run(args);
+   }
+
+   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 Topic object from JNDI
+         Topic topic = (Topic)ic0.lookup("/topic/exampleTopic");
+
+         // 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
+         // and set the client-id
+         connection0 = cf0.createConnection();
+         
+         final String clientID = "my-client-id";
+         
+         connection0.setClientID(clientID);
+
+         // Step 7. We create a JMS Connection connection1 which is a connection to server 1
+         // and set the same client-id
+         connection1 = cf1.createConnection();
+         
+         connection1.setClientID(clientID);
+
+         // 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 durable subscriptions with the same name and client-id on both nodes
+         // of the cluster
+         
+         final String subscriptionName = "my-subscription";
+         
+         MessageConsumer subscriber0 = session0.createDurableSubscriber(topic, subscriptionName);
+
+         MessageConsumer subscriber1 = session1.createDurableSubscriber(topic, subscriptionName);
+
+         Thread.sleep(1000);
+
+         // Step 12. We create a JMS MessageProducer object on server 0
+         MessageProducer producer = session0.createProducer(topic);
+
+         // 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.
+         // Note that the messages have been load-balanced between the two nodes, with some
+         // messages on node 0 and others on node 1.
+         // The "logical" subscription is distributed across the cluster an contains exactly one copy of all the messages
+
+         for (int i = 0; i < numMessages; i +=2)
+         {
+            TextMessage message0 = (TextMessage)subscriber0.receive(5000);
+
+            System.out.println("Got message: " + message0.getText() + " from node 0");
+
+            TextMessage message1 = (TextMessage)subscriber1.receive(5000);
+
+            System.out.println("Got message: " + message1.getText() + " from node 1");
+         }
+
+         return true;
+      }
+      finally
+      {
+         // Step 15. Be sure to close our JMS resources!
+         if (connection0 != null)
+         {
+            connection0.close();
+         }
+
+         if (connection1 != null)
+         {
+            connection1.close();
+         }
+         
+         if (ic0 != null)
+         {
+            ic0.close();
+         }
+
+         if (ic1 != null)
+         {
+            ic1.close();
+         }
+      }
+   }
+
+}

Modified: trunk/examples/jms/clustered-queue/build.xml
===================================================================
--- trunk/examples/jms/clustered-queue/build.xml	2009-04-07 16:36:52 UTC (rev 6344)
+++ trunk/examples/jms/clustered-queue/build.xml	2009-04-07 16:52:42 UTC (rev 6345)
@@ -41,7 +41,7 @@
 
    <target name="runRemote">
       <antcall target="runExample">
-         <param name="example.classname" value="org.jboss.jms.example.QueueExample"/>
+         <param name="example.classname" value="org.jboss.jms.example.ClusteredQueueExample"/>
          <param name="jbm.example.runServer" value="false"/>
       </antcall>
    </target>

Modified: trunk/examples/jms/clustered-queue/src/org/jboss/jms/example/ClusteredQueueExample.java
===================================================================
--- trunk/examples/jms/clustered-queue/src/org/jboss/jms/example/ClusteredQueueExample.java	2009-04-07 16:36:52 UTC (rev 6344)
+++ trunk/examples/jms/clustered-queue/src/org/jboss/jms/example/ClusteredQueueExample.java	2009-04-07 16:52:42 UTC (rev 6345)
@@ -23,6 +23,7 @@
 
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
+import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
 import javax.jms.Queue;
@@ -125,7 +126,7 @@
 
             System.out.println("Got message: " + message1.getText() + " from node 1");
          }
-
+        
          return true;
       }
       finally

Modified: trunk/examples/jms/clustered-topic/readme.html
===================================================================
--- trunk/examples/jms/clustered-topic/readme.html	2009-04-07 16:36:52 UTC (rev 6344)
+++ trunk/examples/jms/clustered-topic/readme.html	2009-04-07 16:52:42 UTC (rev 6345)
@@ -131,9 +131,9 @@
         </pre>
         
         <li>
-        We now consume those messages on *both* server 0 and server 1.
-        We note that all messages have been consumed by *both* consumers.
-        JMS Topics implement *publish-subscribe* messaging where all consumers get a copy of all messages.
+        We now consume those messages on <b>both</b> server 0 and server 1.
+        We note that all messages have been consumed by <b>both</b> consumers.
+        JMS Topics implement <b>publish-subscribe</b> messaging where all consumers get a copy of all messages.
         <pre>
            <code>
 	for (int i = 0; i < numMessages; i ++)




More information about the jboss-cvs-commits mailing list