servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ulhasbh...@apache.org
Subject svn commit: r750936 - in /servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix: Main.java jbi/container/SpringJBIContainer.java jbi/nmr/flow/jca/JCAFlow.java
Date Fri, 06 Mar 2009 15:06:36 GMT
Author: ulhasbhole
Date: Fri Mar  6 15:06:36 2009
New Revision: 750936

URL: http://svn.apache.org/viewvc?rev=750936&view=rev
Log:
[SM-1821] ESB hangs on exit when destroyApplicationContextOnShutdown is set to true and the
broker's persistent storage fails.

Modified:
    servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/Main.java
    servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java
    servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jca/JCAFlow.java

Modified: servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/Main.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/Main.java?rev=750936&r1=750935&r2=750936&view=diff
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/Main.java
(original)
+++ servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/Main.java
Fri Mar  6 15:06:36 2009
@@ -81,13 +81,7 @@
             //this is for classworlds 1.1 launcher which use System.exit() 
             //explicitly after lauch Main. To avoid System.exit() being invoked
             //during servicemix runing, we need keep ServiceMix main thread alive.
-            while (true) {
-                try {
-                    Thread.sleep(60000);
-                } catch (InterruptedException e) {
-                    //
-                }
-            }
+            container.block();
             
         } catch (Exception e) {
             System.out.println("Caught: " + e);

Modified: servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java?rev=750936&r1=750935&r2=750936&view=diff
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java
(original)
+++ servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java
Fri Mar  6 15:06:36 2009
@@ -22,6 +22,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.concurrent.Semaphore;
 
 import javax.jbi.JBIException;
 import javax.jbi.component.Component;
@@ -61,6 +62,7 @@
     private Map components;
     private Map endpoints;
     private Runnable onShutDown;
+    private Semaphore block = new Semaphore(0);
 
     public void afterPropertiesSet() throws Exception {
         init();
@@ -301,6 +303,7 @@
 
     public void destroy() throws Exception {
         super.shutDown();
+        block.release();
     }
 
     public void shutDown() throws JBIException {
@@ -313,6 +316,10 @@
         }
     }
 
+    public void block() throws InterruptedException {
+        block.acquire();
+    }
+
     /**
      * Set a {@link Runnable} which can handle the shutdown of the container
      * 

Modified: servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jca/JCAFlow.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jca/JCAFlow.java?rev=750936&r1=750935&r2=750936&view=diff
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jca/JCAFlow.java
(original)
+++ servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jca/JCAFlow.java
Fri Mar  6 15:06:36 2009
@@ -20,8 +20,12 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.Timer;
+import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.Executors;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.jbi.JBIException;
@@ -88,6 +92,7 @@
 import org.jencks.SingletonEndpointFactory;
 import org.jencks.factory.ConnectionManagerFactoryBean;
 
+
 /**
  * Use for message routing among a network of containers. All
  * routing/registration happens automatically.
@@ -682,10 +687,22 @@
             ra.endpointActivation(endpointFactory, spec);
         }
 
-        public void stop() {
-            ra.endpointDeactivation(endpointFactory, spec);
-            ra.stop();
-            executor.shutdown();
+        public void stop() throws Exception {
+            
+            // In some cases these calls on the resource adapter can be blocked, causing
+            // servicemix to hang on shutdown.
+            FutureTask<Void> task = new FutureTask<Void>(new Callable<Void>()
{
+                    public Void call() {
+                        ra.endpointDeactivation(endpointFactory, spec);
+                        ra.stop();
+                        executor.shutdown();
+                        return null;
+                    }
+                }
+            );
+            
+            Executors.newFixedThreadPool(1).execute(task);
+            task.get(500, TimeUnit.MILLISECONDS);
         }
     }
 



Mime
View raw message