You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/08/27 11:14:32 UTC
svn commit: r1377612 - in /camel/branches/camel-2.9.x: ./
camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
Author: davsclaus
Date: Mon Aug 27 09:14:32 2012
New Revision: 1377612
URL: http://svn.apache.org/viewvc?rev=1377612&view=rev
Log:
CAMEL-5542: Timer component. Avoid firing during CamelContext is starting.
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
Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Merged /camel/trunk:r1377608
Merged /camel/branches/camel-2.10.x:r1377611
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=1377612&r1=1377611&r2=1377612&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 Mon Aug 27 09:14:32 2012
@@ -89,8 +89,9 @@ public class TimerConsumer extends Defau
* 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();
+ // only allow running the timer task if we can run and are not suspended,
+ // and CamelContext must have been fully started
+ return endpoint.getCamelContext().getStatus().isStarted() && isRunAllowed() && !isSuspended();
}
protected void configureTask(TimerTask task, Timer timer) {
@@ -132,12 +133,12 @@ public class TimerConsumer extends Defau
LOG.trace("Timer {} is firing #{} count", endpoint.getTimerName(), counter);
try {
getProcessor().process(exchange);
-
- // log exception if an exception occurred and was not handled
- if (exchange.getException() != null) {
- getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
- }
} catch (Exception e) {
+ exchange.setException(e);
+ }
+
+ // handle any thrown exception
+ if (exchange.getException() != null) {
getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
}
}