Author: davsclaus
Date: Thu Dec  9 10:05:57 2010
New Revision: 1043879

URL: http://svn.apache.org/viewvc?rev=1043879&view=rev
Log:
CAMEL-3417L UoW will now perform on completions (synchronization) before event 
notification about the exchange is done.

Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/util/UnitOfWorkHelper.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java?rev=1043879&r1=1043878&r2=1043879&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
 Thu Dec  9 10:05:57 2010
@@ -162,24 +162,24 @@ public class DefaultUnitOfWork implement
 
         boolean failed = exchange.isFailed();
 
-        // fire event to signal the exchange is done
+        // at first done the synchronizations
+        UnitOfWorkHelper.doneSynchronizations(exchange, synchronizations, LOG);
+
+        // then fire event to signal the exchange is done
         try {
             if (failed) {
                 EventHelper.notifyExchangeFailed(exchange.getContext(), 
exchange);
             } else {
                 EventHelper.notifyExchangeDone(exchange.getContext(), 
exchange);
             }
-        } catch (Exception e) {
+        } catch (Throwable e) {
             // must catch exceptions to ensure synchronizations is also invoked
             LOG.warn("Exception occurred during event notification. This 
exception will be ignored.", e);
-        }
-
-        // done the synchronizations
-        UnitOfWorkHelper.doneSynchronizations(exchange, synchronizations, LOG);
-
-        // unregister from inflight registry
-        if (exchange.getContext() != null) {
-            exchange.getContext().getInflightRepository().remove(exchange);
+        } finally {
+            // unregister from inflight registry
+            if (exchange.getContext() != null) {
+                exchange.getContext().getInflightRepository().remove(exchange);
+            }
         }
     }
 

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/util/UnitOfWorkHelper.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/UnitOfWorkHelper.java?rev=1043879&r1=1043878&r2=1043879&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/util/UnitOfWorkHelper.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/util/UnitOfWorkHelper.java
 Thu Dec  9 10:05:57 2010
@@ -59,7 +59,7 @@ public final class UnitOfWorkHelper {
                         }
                         synchronization.onComplete(exchange);
                     }
-                } catch (Exception e) {
+                } catch (Throwable e) {
                     // must catch exceptions to ensure all synchronizations 
have a chance to run
                     log.warn("Exception occurred during onCompletion. This 
exception will be ignored.", e);
                 }


Reply via email to