[jboss-cvs] JBoss Messaging SVN: r3436 - in branches/Branch_Stable: tests/src/org/jboss/test/messaging/jms/clustering and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Dec 6 16:36:40 EST 2007


Author: timfox
Date: 2007-12-06 16:36:40 -0500 (Thu, 06 Dec 2007)
New Revision: 3436

Modified:
   branches/Branch_Stable/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
   branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java
   branches/Branch_Stable/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
   branches/Branch_Stable/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
   branches/Branch_Stable/tests/src/org/jboss/test/messaging/tools/container/Server.java
Log:
Issue with durable sub failover


Modified: branches/Branch_Stable/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
===================================================================
--- branches/Branch_Stable/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2007-12-06 19:00:46 UTC (rev 3435)
+++ branches/Branch_Stable/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2007-12-06 21:36:40 UTC (rev 3436)
@@ -180,7 +180,7 @@
       this.username = username;
       this.password = password;
 
-      if (failedNodeID > 0)
+      if (failedNodeID >= 0)
       {
          this.failedNodeID = new Integer(failedNodeID);
       }
@@ -305,8 +305,11 @@
             throw new IllegalStateException("Connection is closed");
          }
 
-         if (this.clientID != null)
+         if (this.clientID != null && failedNodeID == null)
          {
+            //For failover we must allow setting client id since this will occur
+            //on failover of connection
+            
             throw new IllegalStateException("Cannot set clientID, already set as " + this.clientID);
          }
 
@@ -735,24 +738,6 @@
    
    // Protected ------------------------------------------------------------------------------------
 
-   /**
-    * Give access to children enpoints to the failed node ID, in case this is a failover connection.
-    * Return null if the connection is regular (not failover).
-    */
-   Integer getFailedNodeID()
-   {
-      return failedNodeID;
-   }
-
-   /**
-    * Tell children enpoints (and anybody from this package, for that matter) whether this
-    * connection is a regular or failover connection.
-    */
-   boolean isFailoverConnection()
-   {
-      return failedNodeID != null;
-   }
-     
    // Private --------------------------------------------------------------------------------------
    
    private void setStarted(boolean s) throws Throwable

Modified: branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java
===================================================================
--- branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java	2007-12-06 19:00:46 UTC (rev 3435)
+++ branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java	2007-12-06 21:36:40 UTC (rev 3436)
@@ -19,12 +19,12 @@
 import javax.jms.QueueBrowser;
 import javax.jms.Session;
 import javax.jms.TextMessage;
+import javax.management.ObjectName;
 
 import org.jboss.jms.client.FailoverEvent;
 import org.jboss.jms.client.JBossConnection;
 import org.jboss.jms.client.delegate.ClientConnectionDelegate;
 import org.jboss.jms.client.remoting.JMSRemotingConnection;
-import org.jboss.test.messaging.jms.clustering.ClusteringTestBase.SimpleFailoverListener;
 import org.jboss.test.messaging.tools.ServerManagement;
 import org.jboss.test.messaging.tools.aop.PoisonInterceptor;
 
@@ -1888,7 +1888,92 @@
       }
    }
     
+   
+   public void testDurableSubscriptionFailoverWithClientIDOnConnectionFactory() throws Exception
+   {
+      Connection conn = null;
+      
+      final String clientID = "ooble";
 
+      ServerManagement.getServer(0).deployConnectionFactory("jboss.messaging.connectionfactory:service=WibbleConnectionFactory",
+                                               new String[] { "/WibbleCF"},
+                                               true, true, clientID);
+      ServerManagement.getServer(1).deployConnectionFactory("jboss.messaging.connectionfactory:service=WibbleConnectionFactory",
+            new String[] { "/WibbleCF"},
+            true, true, clientID);
+      
+      ConnectionFactory myCF = (ConnectionFactory)ic[0].lookup("/WibbleCF");
+      
+      try
+      {
+         conn = createConnectionOnServer(myCF, 1);
+               
+         conn.start();
+
+         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         // register a failover listener
+         SimpleFailoverListener failoverListener = new SimpleFailoverListener();
+         ((JBossConnection)conn).registerFailoverListener(failoverListener);
+         
+         MessageConsumer cons = session.createDurableSubscriber(topic[1], "mysub1");
+         
+         MessageProducer prod = session.createProducer(topic[1]);
+         
+         for (int i = 0; i < 5; i++)
+         {
+            TextMessage tm = session.createTextMessage("message" + i);
+            
+            prod.send(tm);
+         }
+
+         ServerManagement.kill(1);
+
+         // wait for the client-side failover to complete
+
+         while(true)
+         {
+            FailoverEvent event = failoverListener.getEvent(30000);
+            if (event != null && FailoverEvent.FAILOVER_COMPLETED == event.getType())
+            {
+               break;
+            }
+            if (event == null)
+            {
+               fail("Did not get expected FAILOVER_COMPLETED event");
+            }
+         }
+
+         // failover complete
+         assertEquals(0, getServerId(conn));
+         
+         for (int i = 5; i < 10; i++)
+         {
+            TextMessage tm = session.createTextMessage("message" + i);
+            
+            prod.send(tm);
+         }
+         
+         for (int i = 0; i < 10; i++)
+         {
+            TextMessage tm = (TextMessage)cons.receive(30000);
+            
+            assertNotNull(tm);
+            
+            assertEquals("message" + i, tm.getText());
+         }
+      }
+      finally
+      {
+         if (conn != null)
+         {
+            conn.close();
+         }
+         
+         ServerManagement.getServer(0).undeployConnectionFactory(new ObjectName("jboss.messaging.connectionfactory:service=WibbleConnectionFactory"));
+      }
+   }
+
    // Package protected ----------------------------------------------------------------------------
 
    // Protected ------------------------------------------------------------------------------------

Modified: branches/Branch_Stable/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- branches/Branch_Stable/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2007-12-06 19:00:46 UTC (rev 3435)
+++ branches/Branch_Stable/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2007-12-06 21:36:40 UTC (rev 3436)
@@ -709,19 +709,19 @@
                                        String[] jndiBindings,
                                        int prefetchSize) throws Exception
    {
-      deployConnectionFactory(objectName, jndiBindings, prefetchSize, -1, -1, -1, false, false, false);
+      deployConnectionFactory(objectName, jndiBindings, prefetchSize, -1, -1, -1, false, false, false, null);
    }
 
    public void deployConnectionFactory(String objectName,
                                        String[] jndiBindings) throws Exception
    {
-      deployConnectionFactory(objectName, jndiBindings, -1, -1, -1, -1, false, false, false);
+      deployConnectionFactory(objectName, jndiBindings, -1, -1, -1, -1, false, false, false, null);
    }
 
 
     public void deployConnectionFactory(String objectName, String[] jndiBindings, boolean strictTck)  throws Exception
     {
-        deployConnectionFactory(objectName, jndiBindings, -1, -1, -1, -1, false, false, strictTck);
+        deployConnectionFactory(objectName, jndiBindings, -1, -1, -1, -1, false, false, strictTck, null);
     }
 
     public void deployConnectionFactory(String objectName,
@@ -732,7 +732,7 @@
          int defaultTempQueueDownCacheSize) throws Exception
    {
    	this.deployConnectionFactory(objectName, jndiBindings, prefetchSize, defaultTempQueueFullSize,
-   			defaultTempQueuePageSize, defaultTempQueueDownCacheSize, false, false, false);
+   			defaultTempQueuePageSize, defaultTempQueueDownCacheSize, false, false, false, null);
    }
    
    public void deployConnectionFactory(String objectName,
@@ -740,8 +740,16 @@
          boolean supportsFailover, boolean supportsLoadBalancing) throws Exception
    {
    	this.deployConnectionFactory(objectName, jndiBindings, -1, -1,
-   			-1, -1, supportsFailover, supportsLoadBalancing, false);
+   			-1, -1, supportsFailover, supportsLoadBalancing, false, null);
    }
+   
+   public void deployConnectionFactory(String objectName,
+         String[] jndiBindings,
+         boolean supportsFailover, boolean supportsLoadBalancing, String clientID) throws Exception
+   {
+      this.deployConnectionFactory(objectName, jndiBindings, -1, -1,
+            -1, -1, supportsFailover, supportsLoadBalancing, false, clientID);
+   }
 
    private void deployConnectionFactory(String objectName,
                                        String[] jndiBindings,
@@ -751,7 +759,8 @@
                                        int defaultTempQueueDownCacheSize,
                                        boolean supportsFailover,
                                        boolean supportsLoadBalancing,
-                                       boolean strictTck) throws Exception
+                                       boolean strictTck,
+                                       String clientID) throws Exception
    {
       log.trace("deploying connection factory with name: " + objectName);
       
@@ -762,7 +771,12 @@
          "<depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>\n" +
          "<depends optional-attribute-name=\"Connector\">" + ServiceContainer.REMOTING_OBJECT_NAME +
          "</depends>\n";
-
+//<arg type="java.lang.String" value="MyClientID"/>
+      if (clientID != null)
+      {
+         config += "<constructor><arg type=\"java.lang.String\" value=\"" + clientID + "\"/> </constructor>\n";
+      }
+      
       if (defaultTempQueueFullSize != -1)
       {
          config += "<attribute name=\"DefaultTempQueueFullSize\">" + defaultTempQueueFullSize + "</attribute>\n";
@@ -800,6 +814,7 @@
 
       MBeanConfigurationElement mc = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
       ObjectName on = sc.registerAndConfigureService(mc);
+            
       
       log.trace("Object name is now: " + on);
       

Modified: branches/Branch_Stable/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
===================================================================
--- branches/Branch_Stable/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java	2007-12-06 19:00:46 UTC (rev 3435)
+++ branches/Branch_Stable/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java	2007-12-06 21:36:40 UTC (rev 3436)
@@ -425,6 +425,12 @@
    {
    	server.deployConnectionFactory(objectName, jndiBindings, supportsFailover, supportsLoadBalancing);
    }
+   
+   public void deployConnectionFactory(String objectName,
+         String[] jndiBindings, boolean supportsFailover, boolean supportsLoadBalancing, String clientID) throws Exception
+   {
+      server.deployConnectionFactory(objectName, jndiBindings, supportsFailover, supportsLoadBalancing, clientID);
+   }
 
    public void undeployConnectionFactory(ObjectName objectName) throws Exception
    {

Modified: branches/Branch_Stable/tests/src/org/jboss/test/messaging/tools/container/Server.java
===================================================================
--- branches/Branch_Stable/tests/src/org/jboss/test/messaging/tools/container/Server.java	2007-12-06 19:00:46 UTC (rev 3435)
+++ branches/Branch_Stable/tests/src/org/jboss/test/messaging/tools/container/Server.java	2007-12-06 21:36:40 UTC (rev 3436)
@@ -225,6 +225,13 @@
 								         boolean supportsFailover,
 								         boolean supportsLoadBalancing       
 								         ) throws Exception;
+   
+   void deployConnectionFactory(String objectName,
+                              String[] jndiBindings,
+                              boolean supportsFailover,
+                              boolean supportsLoadBalancing,
+                              String clientID
+                              ) throws Exception;
 
    void deployConnectionFactory(String objectName,
                                 String[] jndiBindings,




More information about the jboss-cvs-commits mailing list