servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r721488 - in /servicemix/components/engines/servicemix-camel/trunk/src: main/java/org/apache/servicemix/camel/ test/java/org/apache/servicemix/camel/su8/ test/java/org/apache/servicemix/camel/su9/ test/resources/org/apache/servicemix/camel/...
Date Fri, 28 Nov 2008 13:27:43 GMT
Author: gertv
Date: Fri Nov 28 05:27:43 2008
New Revision: 721488

URL: http://svn.apache.org/viewvc?rev=721488&view=rev
Log:
SM-1686: Inconsistent Exception handling when using RobustInOnly JBI MEP

Modified:
    servicemix/components/engines/servicemix-camel/trunk/src/main/java/org/apache/servicemix/camel/JbiExchange.java
    servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/su8/HandleFaultProcessor.java
    servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/su9/HandleFaultProcessor.java
    servicemix/components/engines/servicemix-camel/trunk/src/test/resources/org/apache/servicemix/camel/su9-src/camel-context.xml

Modified: servicemix/components/engines/servicemix-camel/trunk/src/main/java/org/apache/servicemix/camel/JbiExchange.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-camel/trunk/src/main/java/org/apache/servicemix/camel/JbiExchange.java?rev=721488&r1=721487&r2=721488&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-camel/trunk/src/main/java/org/apache/servicemix/camel/JbiExchange.java
(original)
+++ servicemix/components/engines/servicemix-camel/trunk/src/main/java/org/apache/servicemix/camel/JbiExchange.java
Fri Nov 28 05:27:43 2008
@@ -25,6 +25,7 @@
 import org.apache.camel.CamelContext;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.impl.DefaultExchange;
+import org.apache.servicemix.jbi.exception.FaultException;
 
 /**
  * An {@link org.apache.camel.Exchange} working with JBI which exposes the underlying JBI
@@ -163,6 +164,10 @@
                     if ("fault".equals(name)) {
                         Fault f = messageExchange.createFault();
                         messageExchange.setFault(f);
+                        if (getPattern().equals(ExchangePattern.RobustInOnly)
+                            || getPattern().equals(ExchangePattern.RobustOutOnly)) {    
                       
+                            setException(new FaultException("Fault occured for " + getPattern()
+ " exchange", messageExchange, f));
+                        }                        
                         msg = f;
                     } else {
                         msg = messageExchange.createMessage();

Modified: servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/su8/HandleFaultProcessor.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/su8/HandleFaultProcessor.java?rev=721488&r1=721487&r2=721488&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/su8/HandleFaultProcessor.java
(original)
+++ servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/su8/HandleFaultProcessor.java
Fri Nov 28 05:27:43 2008
@@ -56,8 +56,10 @@
                             if (faultBody instanceof Throwable) {
                                 exchange.setException((Throwable)faultBody);
                             } else {
-                                exchange.setException(new CamelException("Message contains
fault of type "
-                                    + faultBody.getClass().getName() + ":\n" + faultBody));
+                                if (exchange.getException() == null) {
+                                    exchange.setException(new CamelException("Message contains
fault of type "
+                                        + faultBody.getClass().getName() + ":\n" + faultBody));
+                                }
                             }
                         }
                     }                    
@@ -80,8 +82,10 @@
                 if (faultBody instanceof Throwable) {
                     exchange.setException((Throwable)faultBody);
                 } else {
-                    exchange.setException(new CamelException("Message contains fault of type
"
-                        + faultBody.getClass().getName() + ":\n" + faultBody));
+                    if (exchange.getException() == null) {                    
+                        exchange.setException(new CamelException("Message contains fault
of type "
+                            + faultBody.getClass().getName() + ":\n" + faultBody));
+                    }
                 }
             }
         }

Modified: servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/su9/HandleFaultProcessor.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/su9/HandleFaultProcessor.java?rev=721488&r1=721487&r2=721488&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/su9/HandleFaultProcessor.java
(original)
+++ servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/su9/HandleFaultProcessor.java
Fri Nov 28 05:27:43 2008
@@ -56,8 +56,10 @@
                             if (faultBody instanceof Throwable) {
                                 exchange.setException((Throwable)faultBody);
                             } else {
-                                exchange.setException(new CamelException("Message contains
fault of type "
-                                    + faultBody.getClass().getName() + ":\n" + faultBody));
+                                if (exchange.getException() == null) {
+                                    exchange.setException(new CamelException("Message contains
fault of type "
+                                        + faultBody.getClass().getName() + ":\n" + faultBody));
+                                }
                             }
                         }
                     }                    
@@ -80,8 +82,10 @@
                 if (faultBody instanceof Throwable) {
                     exchange.setException((Throwable)faultBody);
                 } else {
-                    exchange.setException(new CamelException("Message contains fault of type
"
-                        + faultBody.getClass().getName() + ":\n" + faultBody));
+                    if (exchange.getException() == null) {                    
+                        exchange.setException(new CamelException("Message contains fault
of type "
+                            + faultBody.getClass().getName() + ":\n" + faultBody));
+                    }
                 }
             }
         }

Modified: servicemix/components/engines/servicemix-camel/trunk/src/test/resources/org/apache/servicemix/camel/su9-src/camel-context.xml
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-camel/trunk/src/test/resources/org/apache/servicemix/camel/su9-src/camel-context.xml?rev=721488&r1=721487&r2=721488&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-camel/trunk/src/test/resources/org/apache/servicemix/camel/su9-src/camel-context.xml
(original)
+++ servicemix/components/engines/servicemix-camel/trunk/src/test/resources/org/apache/servicemix/camel/su9-src/camel-context.xml
Fri Nov 28 05:27:43 2008
@@ -29,8 +29,8 @@
     <route errorHandlerRef="deadLetterErrorHandler">
       <from uri="jbi:service:urn:test:fault-handled-true"/>
       <onException>
-        <!-- Catch exception from in-only message exchange -->
-        <exception>org.apache.servicemix.jbi.FaultException</exception>
+        <!-- Catch exception from in-only/robust-in-only message exchange. -->
+        <exception>org.apache.servicemix.jbi.exception.FaultException</exception>
         <redeliveryPolicy maximumRedeliveries="0"/>
         <handled>
           <constant>true</constant>
@@ -38,14 +38,20 @@
         <to uri="jbi:service:urn:test:receiver-service"/>
       </onException>
       <onException>
-        <!-- Catch exception from robust-in-only message exchange -->
-        <exception>org.apache.camel.CamelException</exception>
+        <!-- This clause is needed for testing since the test client still
+             throws the older org.apache.servicemix.jbi.FaultException. You 
+             only need to catch org.apache.servicemix.jbi.exception.FaultException 
+             in runtime scenarios.
+             
+             TODO remove this when ServiceMix 3.3.1 is released.
+             -->
+        <exception>org.apache.servicemix.jbi.FaultException</exception>
         <redeliveryPolicy maximumRedeliveries="0"/>
         <handled>
           <constant>true</constant>
         </handled>
         <to uri="jbi:service:urn:test:receiver-service"/>
-      </onException>
+      </onException>      
       <interceptor ref="handleFaultProcessor">
         <to uri="jbi:service:urn:test:faulty-service"/>
       </interceptor>



Mime
View raw message