Author: davsclaus
Date: Mon Oct 11 15:57:39 2010
New Revision: 1021396
URL: http://svn.apache.org/viewvc?rev=1021396&view=rev
Log:
CAMEL-3216: Fixed scheduled poll to not let thread die, to ensure the scheduler
keeps running.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyRollbackThrowExceptionTest.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java?rev=1021396&r1=1021395&r2=1021396&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java
Mon Oct 11 15:57:39 2010
@@ -112,15 +112,23 @@ public abstract class ScheduledPollConsu
if (retry) {
done = false;
}
- } catch (Exception re) {
- throw ObjectHelper.wrapRuntimeCamelException(re);
+ } catch (Throwable t) {
+ // catch throwable to not let the thread die
+ // log the fatal error as the JDK itself may not log it
for us
+ log.fatal("Consumer " + this + " could not poll endpoint:
" + getEndpoint().getEndpointUri() + " caused by: " + t.getMessage(), t);
+ // we are done due this fatal error
+ done = true;
}
- } catch (Error e) {
+ } catch (Throwable t) {
+ // catch throwable to not let the thread die
// log the fatal error as the JDK itself may not log it for us
- log.fatal("Consumer " + this + " could not poll endpoint: " +
getEndpoint().getEndpointUri() + " caused by: " + e.getMessage(), e);
- throw e;
+ log.fatal("Consumer " + this + " could not poll endpoint: " +
getEndpoint().getEndpointUri() + " caused by: " + t.getMessage(), t);
+ // we are done due this fatal error
+ done = true;
}
}
+
+ // avoid this thread to throw exceptions because the thread pool wont
re-schedule a new thread
}
// Properties
Modified:
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyRollbackThrowExceptionTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyRollbackThrowExceptionTest.java?rev=1021396&r1=1021395&r2=1021396&view=diff
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyRollbackThrowExceptionTest.java
(original)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPollStrategyRollbackThrowExceptionTest.java
Mon Oct 11 15:57:39 2010
@@ -53,13 +53,13 @@ public class FileConsumerPollStrategyRol
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(0);
- // let it run for a little while since we rethrow the exception the
consumer
- // will stop scheduling and not poll anymore
+ // let it run for a little, but it fails all the time
Thread.sleep(2000);
assertMockEndpointsSatisfied();
- assertEquals("rollback", event);
+ // and we should rollback X number of times
+ assertTrue(event.startsWith("rollback"));
}
protected RouteBuilder createRouteBuilder() throws Exception {