[hornetq-commits] JBoss hornetq SVN: r9109 - in trunk: tests/src/org/hornetq/tests/integration/jms/bridge and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Apr 14 05:07:06 EDT 2010


Author: jmesnil
Date: 2010-04-14 05:07:05 -0400 (Wed, 14 Apr 2010)
New Revision: 9109

Modified:
   trunk/src/main/org/hornetq/jms/bridge/impl/JMSBridgeImpl.java
   trunk/tests/src/org/hornetq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-287: cannot stop JMSBridge which is handling startup failure

* added check in JMSBridgeImple.setupJMSObjectsWithRetry to exit the infinite loop if the bridge is stopping

Modified: trunk/src/main/org/hornetq/jms/bridge/impl/JMSBridgeImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/bridge/impl/JMSBridgeImpl.java	2010-04-13 15:16:44 UTC (rev 9108)
+++ trunk/src/main/org/hornetq/jms/bridge/impl/JMSBridgeImpl.java	2010-04-14 09:07:05 UTC (rev 9109)
@@ -108,6 +108,8 @@
 
    private boolean started;
 
+   private boolean stopping = false;
+
    private final LinkedList<Message> messages;
 
    private ConnectionFactoryFactory sourceCff;
@@ -305,6 +307,8 @@
 
    public synchronized void start() throws Exception
    {
+      stopping = false; 
+
       if (started)
       {
          JMSBridgeImpl.log.warn("Attempt to start, but is already started");
@@ -386,6 +390,8 @@
 
    public synchronized void stop() throws Exception
    {
+      stopping = true;
+
       if (!started)
       {
          JMSBridgeImpl.log.warn("Attempt to stop, but is already stopped");
@@ -1366,7 +1372,7 @@
 
       int count = 0;
 
-      while (true)
+      while (true && !stopping)
       {
          boolean ok = setupJMSObjects();
 

Modified: trunk/tests/src/org/hornetq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java	2010-04-13 15:16:44 UTC (rev 9108)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java	2010-04-14 09:07:05 UTC (rev 9109)
@@ -12,6 +12,8 @@
  */
 package org.hornetq.tests.integration.jms.bridge;
 
+import java.lang.management.ManagementFactory;
+
 import junit.framework.Assert;
 
 import org.hornetq.core.logging.Logger;
@@ -139,6 +141,54 @@
       }
    }
 
+   /**
+    * https://jira.jboss.org/jira/browse/HORNETQ-287
+    */
+   public void testStopBridgeWithFailureWhenStarted() throws Exception
+   {
+      jmsServer1.stop();
+
+      long failureRetryInterval = 500;
+      
+      JMSBridgeImpl bridge = new JMSBridgeImpl(cff0,
+                                               cff1,
+                                               sourceQueueFactory,
+                                               targetQueueFactory,
+                                               null,
+                                               null,
+                                               null,
+                                               null,
+                                               null,
+                                               500,
+                                               -1,
+                                               QualityOfServiceMode.DUPLICATES_OK,
+                                               10,
+                                               -1,
+                                               null,
+                                               null,
+                                               false);
+      bridge.setTransactionManager(newTransactionManager());
+
+      bridge.start();
+      Assert.assertFalse(bridge.isStarted());
+      Assert.assertTrue(bridge.isFailed());
+
+      int numThreads = ManagementFactory.getThreadMXBean().getThreadCount();
+      
+      bridge.stop();
+      Thread.sleep(failureRetryInterval * 2);
+
+      // the JMS Brigde failure handler thread must have been stopped at most 1 failureRetryInterval ms after the bridge is stopped
+      assertEquals(numThreads - 1, ManagementFactory.getThreadMXBean().getThreadCount());
+      Assert.assertFalse(bridge.isStarted());
+
+      // we restart and setup the server for the test's tearDown checks
+      jmsServer1.start();
+      createQueue("targetQueue", 1);
+      setUpAdministeredObjects();
+
+   }
+   
    /*
     * Send some messages
     * Crash the destination server



More information about the hornetq-commits mailing list