camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1309948 - in /camel/branches/camel-2.9.x: ./ camel-core/src/main/java/org/apache/camel/component/timer/ camel-core/src/test/java/org/apache/camel/component/timer/
Date Thu, 05 Apr 2012 17:06:21 GMT
Author: davsclaus
Date: Thu Apr  5 17:06:21 2012
New Revision: 1309948

URL: http://svn.apache.org/viewvc?rev=1309948&view=rev
Log:
CAMEL-5137: Fixed timer component suspend/resume issue.

Added:
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/timer/TimerSuspendCamelContextTest.java
      - copied unchanged from r1309945, camel/trunk/camel-core/src/test/java/org/apache/camel/component/timer/TimerSuspendCamelContextTest.java
Modified:
    camel/branches/camel-2.9.x/   (props changed)
    camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/timer/TimerRestartTest.java

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1309945

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

Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java?rev=1309948&r1=1309947&r2=1309948&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
(original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
Thu Apr  5 17:06:21 2012
@@ -50,6 +50,11 @@ public class TimerConsumer extends Defau
 
             @Override
             public void run() {
+                if (!isTaskRunAllowed()) {
+                    // do not run timer task as it was not allowed
+                    return;
+                }
+
                 try {
                     long count = counter.incrementAndGet();
 
@@ -80,6 +85,14 @@ public class TimerConsumer extends Defau
         task = null;
     }
 
+    /**
+     * Whether the timer task is allow to run or not
+     */
+    protected boolean isTaskRunAllowed() {
+        // only allow running the timer task if we can run and are not suspended
+        return isRunAllowed() && !isSuspended();
+    }
+
     protected void configureTask(TimerTask task, Timer timer) {
         if (endpoint.isFixedRate()) {
             if (endpoint.getTime() != null) {

Modified: camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/timer/TimerRestartTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/timer/TimerRestartTest.java?rev=1309948&r1=1309947&r2=1309948&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/timer/TimerRestartTest.java
(original)
+++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/timer/TimerRestartTest.java
Thu Apr  5 17:06:21 2012
@@ -31,7 +31,11 @@ public class TimerRestartTest extends Co
 
         assertMockEndpointsSatisfied();
 
+        mock.reset();
+        mock.expectedMessageCount(0);
+
         context.stop();
+        Thread.sleep(2000);
 
         mock.reset();
 



Mime
View raw message