[hornetq-commits] JBoss hornetq SVN: r9017 - trunk/src/main/org/hornetq/ra/inflow.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Mar 30 19:24:47 EDT 2010


Author: clebert.suconic at jboss.com
Date: 2010-03-30 19:24:46 -0400 (Tue, 30 Mar 2010)
New Revision: 9017

Modified:
   trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java
Log:
fixing races on setup / teardown

Modified: trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java
===================================================================
--- trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java	2010-03-30 16:51:10 UTC (rev 9016)
+++ trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java	2010-03-30 23:24:46 UTC (rev 9017)
@@ -220,7 +220,6 @@
    }
 
    
-   
    /**
     * Start the activation
     *
@@ -255,7 +254,7 @@
    /**
     * Stop the activation
     */
-   public void stop()
+   public void stop() throws ResourceException
    {
       if (HornetQActivation.trace)
       {
@@ -263,7 +262,7 @@
       }
 
       deliveryActive.set(false);
-      teardown();
+      ra.getWorkManager().scheduleWork(new TearDownActivation());
    }
 
    /**
@@ -271,9 +270,9 @@
     *
     * @throws Exception Thrown if an error occurs
     */
-   protected void setup() throws Exception
+   protected synchronized void setup() throws Exception
    {
-      HornetQActivation.log.debug("Setting up " + spec);
+      HornetQActivation.log.info("Setting up " + spec);
 
       setupCF();
 
@@ -288,15 +287,15 @@
          handlers.add(handler);
       }
 
-      HornetQActivation.log.debug("Setup complete " + this);
+      HornetQActivation.log.info("Setup complete " + this);
    }
 
    /**
     * Teardown the activation
     */
-   protected void teardown()
+   protected synchronized void teardown()
    {
-      HornetQActivation.log.debug("Tearing down " + spec);
+      HornetQActivation.log.info("Tearing down " + spec);
 
       for (HornetQMessageHandler handler : handlers)
       {
@@ -307,7 +306,7 @@
          factory.close();
          factory = null;
       }
-      HornetQActivation.log.debug("Tearing down complete " + this);
+      HornetQActivation.log.info("Tearing down complete " + this);
    }
 
    protected void setupCF() throws Exception
@@ -497,7 +496,7 @@
          }
          catch (Throwable t)
          {
-            HornetQActivation.log.error("Unabler to start activation ", t);
+            HornetQActivation.log.error("Unable to start activation ", t);
          }
       }
 
@@ -505,4 +504,26 @@
       {
       }
    }
+
+   /**
+    * Handles the setup
+    */
+   private class TearDownActivation implements Work
+   {
+      public void run()
+      {
+         try
+         {
+            teardown();
+         }
+         catch (Throwable t)
+         {
+            HornetQActivation.log.error("Unable to tear down activation ", t);
+         }
+      }
+
+      public void release()
+      {
+      }
+   }
 }



More information about the hornetq-commits mailing list