camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1381554 - in /camel/branches/camel-2.10.x: ./ camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/test/java/org/apache/camel...
Date Thu, 06 Sep 2012 11:02:22 GMT
Author: davsclaus
Date: Thu Sep  6 11:02:21 2012
New Revision: 1381554

URL: http://svn.apache.org/viewvc?rev=1381554&view=rev
Log:
CAMEL-5573: Redelivery error handler only need thread pool if redelivery is enabeled.

Modified:
    camel/branches/camel-2.10.x/   (props changed)
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
    camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/impl/MultipleLifecycleStrategyTest.java

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1381552

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java?rev=1381554&r1=1381553&r2=1381554&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
Thu Sep  6 11:02:21 2012
@@ -419,8 +419,9 @@ public class DefaultErrorHandlerBuilder 
                     throw new IllegalArgumentException("ExecutorServiceRef " + executorServiceRef
+ " not found in registry.");
                 }
             } else {
-                // use default shared thread pool for error handlers
-                executorService = camelContext.getErrorHandlerExecutorService();
+                // no explicit configured thread pool, so leave it up to the error handler
to deceide if it need
+                // a default thread pool from CamelContext#getErrorHandlerExecutorService
+                executorService = null;
             }
         }
         return executorService;

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=1381554&r1=1381553&r2=1381554&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
Thu Sep  6 11:02:21 2012
@@ -1280,7 +1280,11 @@ public class DefaultCamelContext extends
         this.errorHandlerBuilder = errorHandlerBuilder;
     }
 
-    public ScheduledExecutorService getErrorHandlerExecutorService() {
+    public synchronized ScheduledExecutorService getErrorHandlerExecutorService() {
+        if (errorHandlerExecutorService == null) {
+            // setup default thread pool for error handler
+            errorHandlerExecutorService = getExecutorServiceManager().newDefaultScheduledThreadPool("ErrorHandlerRedeliveryThreadPool",
"ErrorHandlerRedeliveryTask");
+        }
         return errorHandlerExecutorService;
     }
 
@@ -1563,11 +1567,6 @@ public class DefaultCamelContext extends
         // start components
         startServices(components.values());
 
-        // setup default thread pool for error handler
-        if (errorHandlerExecutorService == null || errorHandlerExecutorService.isShutdown())
{
-            errorHandlerExecutorService = getExecutorServiceManager().newDefaultScheduledThreadPool("ErrorHandlerRedeliveryThreadPool",
"ErrorHandlerRedeliveryTask");
-        }
-
         // start the route definitions before the routes is started
         startRouteDefinitions(routeDefinitions);
 

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java?rev=1381554&r1=1381553&r2=1381554&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
Thu Sep  6 11:02:21 2012
@@ -283,6 +283,10 @@ public abstract class RedeliveryErrorHan
                     // okay there is a delay so create a scheduled task to have it executed
in the future
 
                     if (data.currentRedeliveryPolicy.isAsyncDelayedRedelivery() &&
!exchange.isTransacted()) {
+
+                        // we are doing a redelivery then a thread pool must be configured
(see the doStart method)
+                        ObjectHelper.notNull(executorService, "Redelivery is enabled but
ExecutorService has not been configured.", this);
+
                         // let the RedeliverTask be the logic which tries to redeliver the
Exchange which we can used a scheduler to
                         // have it being executed in the future, or immediately
                         // we are continuing asynchronously
@@ -442,6 +446,9 @@ public abstract class RedeliveryErrorHan
         }
 
         if (data.redeliveryCounter > 0) {
+            // we are doing a redelivery then a thread pool must be configured (see the doStart
method)
+            ObjectHelper.notNull(executorService, "Redelivery is enabled but ExecutorService
has not been configured.", this);
+
             // let the RedeliverTask be the logic which tries to redeliver the Exchange which
we can used a scheduler to
             // have it being executed in the future, or immediately
             // Note: the data.redeliverFromSync should be kept as is, in case it was enabled
previously
@@ -1048,16 +1055,22 @@ public abstract class RedeliveryErrorHan
     protected void doStart() throws Exception {
         ServiceHelper.startServices(output, outputAsync, deadLetter);
 
-        if (executorService == null) {
-            // use default shared executor service
-            executorService = camelContext.getErrorHandlerExecutorService();
-        }
-
         // determine if redeliver is enabled or not
         redeliveryEnabled = determineIfRedeliveryIsEnabled();
         if (log.isDebugEnabled()) {
             log.debug("Redelivery enabled: {} on error handler: {}", redeliveryEnabled, this);
         }
+
+        // we only need thread pool if redelivery is enabled
+        if (redeliveryEnabled) {
+            if (executorService == null) {
+                // use default shared executor service
+                executorService = camelContext.getErrorHandlerExecutorService();
+            }
+            if (log.isTraceEnabled()) {
+                log.trace("Using ExecutorService: {} for redeliveries on error handler: {}",
executorService, this);
+            }
+        }
     }
 
     @Override

Modified: camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/impl/MultipleLifecycleStrategyTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/impl/MultipleLifecycleStrategyTest.java?rev=1381554&r1=1381553&r2=1381554&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/impl/MultipleLifecycleStrategyTest.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/impl/MultipleLifecycleStrategyTest.java
Thu Sep  6 11:02:21 2012
@@ -51,7 +51,7 @@ public class MultipleLifecycleStrategyTe
         context.stop();
 
         List<String> expectedEvents = Arrays.asList("onContextStart", "onServiceAdd",
"onServiceAdd", "onServiceAdd",
-                "onServiceAdd", "onServiceAdd", "onServiceAdd", "onServiceAdd", "onThreadPoolAdd",
"onServiceAdd",
+                "onServiceAdd", "onServiceAdd", "onServiceAdd", "onServiceAdd", "onServiceAdd",
                 "onThreadPoolAdd", "onComponentAdd", "onEndpointAdd", "onComponentRemove",
"onContextStop");
 
         assertEquals(expectedEvents, dummy1.getEvents());



Mime
View raw message