Author: davsclaus
Date: Mon Aug 27 09:13:07 2012
New Revision: 1377611
URL: http://svn.apache.org/viewvc?rev=1377611&view=rev
Log:
CAMEL-5542: Timer component. Avoid firing during CamelContext is starting.
Modified:
camel/branches/camel-2.10.x/ (props changed)
camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Merged /camel/trunk:r1377608
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/component/timer/TimerConsumer.java
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java?rev=1377611&r1=1377610&r2=1377611&view=diff
==============================================================================
---
camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
(original)
+++
camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
Mon Aug 27 09:13:07 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());
}
}