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 2011/01/19 12:19:05 UTC
svn commit: r1060768 - in /camel/trunk:
camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java
components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
examples/camel-example-management/
Author: davsclaus
Date: Wed Jan 19 11:19:04 2011
New Revision: 1060768
URL: http://svn.apache.org/viewvc?rev=1060768&view=rev
Log:
CAMEL-3560: Added fallback in UoWProcessor to catch unhandled exceptions and ensure UoW is done. This prevents in-flight registry to be tracked propertly, ensure graceful shutdown doesnt hit timeout due 1 message stuck.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java
camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
camel/trunk/examples/camel-example-management/ (props changed)
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java?rev=1060768&r1=1060767&r2=1060768&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java Wed Jan 19 11:19:04 2011
@@ -92,21 +92,35 @@ public final class UnitOfWorkProcessor e
try {
uow.start();
} catch (Exception e) {
- throw wrapRuntimeCamelException(e);
+ callback.done(true);
+ exchange.setException(e);
+ return true;
}
// process the exchange
- return processor.process(exchange, new AsyncCallback() {
- public void done(boolean doneSync) {
- // Order here matters. We need to complete the callbacks
- // since they will likely update the exchange with some final results.
- try {
- callback.done(doneSync);
- } finally {
- doneUow(uow, exchange);
+ try {
+ return processor.process(exchange, new AsyncCallback() {
+ public void done(boolean doneSync) {
+ // Order here matters. We need to complete the callbacks
+ // since they will likely update the exchange with some final results.
+ try {
+ callback.done(doneSync);
+ } finally {
+ doneUow(uow, exchange);
+ }
}
+ });
+ } catch (Throwable e) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Caught unhandled exception while processing ExchangeId: " + exchange.getExchangeId(), e);
}
- });
+ // fallback and catch any exceptions the process may not have caught
+ // we must ensure to done the UoW in all cases and issue done on the callback
+ doneUow(uow, exchange);
+ exchange.setException(e);
+ callback.done(true);
+ return true;
+ }
} else {
// There was an existing UoW, so we should just pass through..
// so that the guy the initiated the UoW can terminate it.
Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java?rev=1060768&r1=1060767&r2=1060768&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java (original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java Wed Jan 19 11:19:04 2011
@@ -87,8 +87,12 @@ public class EndpointMessageListener imp
if (correlationId != null) {
LOG.debug("Received Message has JMSCorrelationID [" + correlationId + "]");
}
-
- processor.process(exchange);
+
+ try {
+ processor.process(exchange);
+ } catch (Throwable e) {
+ exchange.setException(e);
+ }
if (LOG.isTraceEnabled()) {
LOG.trace("onMessage.process END");
}
Propchange: camel/trunk/examples/camel-example-management/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Jan 19 11:19:04 2011
@@ -1,7 +1,9 @@
-.project
-.checkstyle
+eclipse-classes
.pmd
+.checkstyle
+.project
.classpath
target
.settings
-eclipse-classes
+activemq-data
+*.i??