[jboss-cvs] JBoss Messaging SVN: r4106 - in branches/Branch_JBossMessaging_1_4_0_SP3_CP: tests/src/org/jboss/test/messaging/jms/bridge and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 23 19:50:03 EDT 2008


Author: clebert.suconic at jboss.com
Date: 2008-04-23 19:50:03 -0400 (Wed, 23 Apr 2008)
New Revision: 4106

Added:
   branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/bridge/SimpleCrashWithRestartTest.java
Modified:
   branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/server/bridge/Bridge.java
Log:
JBMESSAGING-1278 - using a separate thread to close JMS Connections, avoiding conflicts with remoting

Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/server/bridge/Bridge.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/server/bridge/Bridge.java	2008-04-23 14:31:11 UTC (rev 4105)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/server/bridge/Bridge.java	2008-04-23 23:50:03 UTC (rev 4106)
@@ -1081,29 +1081,36 @@
    
    private void cleanup()
    {
+	   // Using just a plain thread to close this, as this failure shouldn't be happening very oftenly
+	  class ThreadCloser extends Thread
+	  {
+		  Connection connections[];
+		  ThreadCloser(Connection ... connections)
+		  {
+			  this.connections = connections;
+		  }
+		  
+		  public void run()
+		  {
+			  for (int i=0; i< connections.length; i++)
+			  {
+	           log.debug("Closing connection " + (i==0?"(source)":"(target)") );
+				  try
+				  {
+					  connections[i].close();
+				  }
+				  catch (Exception ignored)
+				  {
+					  log.trace("Error closing " + (i==0?"source":"target")  + " connection:", ignored);
+				  }
+			  }
+		  }
+	  }
+	  new ThreadCloser(sourceConn, targetConn).start();
+	  
+	  sourceConn = null;
+	  targetConn = null;
    	
-      //Close the old objects
-      try
-      {
-         sourceConn.close();
-      }
-      catch (Throwable ignore)
-      {            
-      	if (trace) { log.trace("Failed to close source connection", ignore); }
-      }
-      try
-      {
-         if (targetConn != null)
-         {
-            targetConn.close();
-         }
-      }
-      catch (Throwable ignore)
-      {    
-      	if (trace) { log.trace("Failed to close target connection", ignore); }
-      }
-
-   	
       if (tx != null)
       {
          try

Added: branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/bridge/SimpleCrashWithRestartTest.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/bridge/SimpleCrashWithRestartTest.java	                        (rev 0)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/bridge/SimpleCrashWithRestartTest.java	2008-04-23 23:50:03 UTC (rev 4106)
@@ -0,0 +1,274 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.test.messaging.jms.bridge;
+
+import java.util.Properties;
+
+import org.jboss.jms.jndi.JMSProviderAdapter;
+import org.jboss.jms.server.bridge.Bridge;
+import org.jboss.logging.Logger;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.TestJMSProviderAdaptor;
+import org.jboss.test.messaging.tools.aop.PoisonInterceptor;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ *
+ */
+public class SimpleCrashWithRestartTest extends BridgeTestBase
+{
+   private static final Logger log = Logger.getLogger(ReconnectTest.class);
+
+   public SimpleCrashWithRestartTest(String name)
+   {
+      super(name);
+   }
+
+   protected void setUp() throws Exception
+   {   
+      super.setUp();         
+      
+      //Now install local JMSProviderAdaptor classes
+      
+      Properties props1 = new Properties();
+      props1.putAll(ServerManagement.getJNDIEnvironment(1));
+        
+      JMSProviderAdapter targetAdaptor =
+         new TestJMSProviderAdaptor(props1, "/XAConnectionFactory", "adaptor1");
+      
+      sc.installJMSProviderAdaptor("adaptor1", targetAdaptor);
+      
+      sc.startRecoveryManager();      
+   }
+
+   protected void tearDown() throws Exception
+   {  
+      super.tearDown();
+
+      sc.stopRecoveryManager();
+      
+      sc.uninstallJMSProviderAdaptor("adaptor1");
+
+      log.debug(this + " torn down");
+   }
+      
+   /*
+    * Send some messages   
+    * Crash the server after prepare but on commit
+    * Bring up the destination server
+    * Send some more messages
+    * Verify all messages are received
+    */
+   public void testCrashAndRestart() throws Exception
+   {
+	      Bridge bridge = null;
+          
+	      try
+	      {
+	         final int NUM_MESSAGES = 10;         
+	         
+	         bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
+	                  null, null, null, null,
+	                  null, 1000, -1, Bridge.QOS_AT_MOST_ONCE,
+	                  NUM_MESSAGES, -1,
+	                  null, null, false);
+	         
+	         bridge.start();
+	         
+	         sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES, true);
+	              
+	         checkMessagesReceived(cf1, targetQueue, Bridge.QOS_ONCE_AND_ONLY_ONCE, NUM_MESSAGES, true);
+	         
+	         ServerManagement.kill(1);
+	         
+	         
+	         // >30 sec (timeout on remoting)
+	         Thread.sleep(35000);
+	         
+	       	ServerManagement.start(1, "all", false);
+	      	ServerManagement.deployQueue("targetQueue", 1);     
+	       	
+	       	setUpAdministeredObjects();
+	       	
+	         sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES, true);
+             
+	         checkMessagesReceived(cf1, targetQueue, Bridge.QOS_AT_MOST_ONCE, NUM_MESSAGES, true);
+	      }
+	      finally
+	      {      
+	         if (bridge != null)
+	         {
+	            try
+	            {
+	               bridge.stop();
+	            }
+	            catch (Exception e)
+	            {
+	               log.error("Failed to stop bridge", e);
+	            }
+	         }
+	      }                  
+   }
+   
+   // Inner classes -------------------------------------------------------------------   
+}
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.test.messaging.jms.bridge;
+
+import java.util.Properties;
+
+import org.jboss.jms.jndi.JMSProviderAdapter;
+import org.jboss.jms.server.bridge.Bridge;
+import org.jboss.logging.Logger;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.TestJMSProviderAdaptor;
+import org.jboss.test.messaging.tools.aop.PoisonInterceptor;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ *
+ */
+public class SimpleCrashWithRestartTest extends BridgeTestBase
+{
+   private static final Logger log = Logger.getLogger(ReconnectTest.class);
+
+   public SimpleCrashWithRestartTest(String name)
+   {
+      super(name);
+   }
+
+   protected void setUp() throws Exception
+   {   
+      super.setUp();         
+      
+      //Now install local JMSProviderAdaptor classes
+      
+      Properties props1 = new Properties();
+      props1.putAll(ServerManagement.getJNDIEnvironment(1));
+        
+      JMSProviderAdapter targetAdaptor =
+         new TestJMSProviderAdaptor(props1, "/XAConnectionFactory", "adaptor1");
+      
+      sc.installJMSProviderAdaptor("adaptor1", targetAdaptor);
+      
+      sc.startRecoveryManager();      
+   }
+
+   protected void tearDown() throws Exception
+   {  
+      super.tearDown();
+
+      sc.stopRecoveryManager();
+      
+      sc.uninstallJMSProviderAdaptor("adaptor1");
+
+      log.debug(this + " torn down");
+   }
+      
+   /*
+    * Send some messages   
+    * Crash the server after prepare but on commit
+    * Bring up the destination server
+    * Send some more messages
+    * Verify all messages are received
+    */
+   public void testCrashAndRestart() throws Exception
+   {
+	      Bridge bridge = null;
+          
+	      try
+	      {
+	         final int NUM_MESSAGES = 10;         
+	         
+	         bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
+	                  null, null, null, null,
+	                  null, 1000, -1, Bridge.QOS_AT_MOST_ONCE,
+	                  NUM_MESSAGES, -1,
+	                  null, null, false);
+	         
+	         bridge.start();
+	         
+	         sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES, true);
+	              
+	         checkMessagesReceived(cf1, targetQueue, Bridge.QOS_AT_MOST_ONCE, NUM_MESSAGES, true);
+	         
+	         ServerManagement.kill(1);
+	         
+	         
+	         // >30 sec (timeout on remoting)
+	         Thread.sleep(35000);
+	         
+	       	ServerManagement.start(1, "all", false);
+	      	ServerManagement.deployQueue("targetQueue", 1);     
+	       	
+	       	setUpAdministeredObjects();
+	       	
+	         sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES, true);
+             
+	         checkMessagesReceived(cf1, targetQueue, Bridge.QOS_AT_MOST_ONCE, NUM_MESSAGES, true);
+	      }
+	      finally
+	      {      
+	         if (bridge != null)
+	         {
+	            try
+	            {
+	               bridge.stop();
+	            }
+	            catch (Exception e)
+	            {
+	               log.error("Failed to stop bridge", e);
+	            }
+	         }
+	      }                  
+   }
+   
+   // Inner classes -------------------------------------------------------------------   
+}
+


Property changes on: branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/bridge/SimpleCrashWithRestartTest.java
___________________________________________________________________
Name: svn:keywords
   + Id LastChangedDate Author Revision




More information about the jboss-cvs-commits mailing list