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 2009/12/02 09:53:18 UTC
svn commit: r886075 - in /camel/branches/camel-1.x: ./
camel-core/src/main/java/org/apache/camel/processor/
camel-core/src/test/java/org/apache/camel/processor/routingslip/
Author: davsclaus
Date: Wed Dec 2 08:53:17 2009
New Revision: 886075
URL: http://svn.apache.org/viewvc?rev=886075&view=rev
Log:
Merged revisions 885876 via svnmerge from
https://svn.apache.org/repos/asf/camel/trunk
........
r885876 | janstey | 2009-12-01 20:19:25 +0100 (Tue, 01 Dec 2009) | 1 line
CAMEL-2245 - stop routing slip when exchange is failed
........
Added:
camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipWithErrorHandlerTest.java
- copied unchanged from r885876, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipWithErrorHandlerTest.java
Modified:
camel/branches/camel-1.x/ (props changed)
camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipWithExceptionTest.java
Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec 2 08:53:17 2009
@@ -1 +1 @@
-/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781,774192,774383,774658-774659,776198,776289,776504,776975,778102,778689-778701,779121,779143,779489,781314-781349,781775,781
923,781974,781993,782557,782594,782681,782886,782918-782923,783204,783248,783363,783639,783704,785564,785584,785599,787206,787581,787598,787605,787928,788393,789121,789703,790560,790936,791379,791476,791767,792038,792381,792398,792899,793359,793518,793547-793555,793862,793935,794237,794368,794550,794967,795790,798027,798052,798063,798489,798864,799252,800340,800785,800797,801084,801196,801960,802307,802478,803559,807476,810751,812937,814493,816105,817654,818063,818182-818354,818744,818747,819475,819956,820152,820168,821272,821290,822655,823013,823018,823031,823102,823177,823575,824218,824721,825760,825765,828288,828333,832647,833285,833289,833350,833370,833381,833419,835511,880655,880667,883713,884525,884750
+/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781,774192,774383,774658-774659,776198,776289,776504,776975,778102,778689-778701,779121,779143,779489,781314-781349,781775,781
923,781974,781993,782557,782594,782681,782886,782918-782923,783204,783248,783363,783639,783704,785564,785584,785599,787206,787581,787598,787605,787928,788393,789121,789703,790560,790936,791379,791476,791767,792038,792381,792398,792899,793359,793518,793547-793555,793862,793935,794237,794368,794550,794967,795790,798027,798052,798063,798489,798864,799252,800340,800785,800797,801084,801196,801960,802307,802478,803559,807476,810751,812937,814493,816105,817654,818063,818182-818354,818744,818747,819475,819956,820152,820168,821272,821290,822655,823013,823018,823031,823102,823177,823575,824218,824721,825760,825765,828288,828333,832647,833285,833289,833350,833370,833381,833419,835511,880655,880667,883713,884525,884750,885876
Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java?rev=886075&r1=886074&r2=886075&view=diff
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java (original)
+++ camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java Wed Dec 2 08:53:17 2009
@@ -16,10 +16,8 @@
*/
package org.apache.camel.processor;
-
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
@@ -42,7 +40,6 @@
private static final transient Log LOG = LogFactory.getLog(RoutingSlip.class);
private final String header;
private final String uriDelimiter;
-
private ProducerCache<Exchange> producerCache = new ProducerCache<Exchange>();
public RoutingSlip(String header) {
@@ -75,9 +72,27 @@
updateRoutingSlip(current);
copyOutToIn(ex, current);
- producer.process(ex);
+ try {
+ producer.process(ex);
+ } catch (Exception e) {
+ ex.setException(e);
+ }
current = ex;
+
+ boolean exceptionHandled = hasExceptionBeenHandled(current);
+ if (current.isFailed() || exceptionHandled) {
+ // The Exchange.EXCEPTION_HANDLED_PROPERTY property is only set if satisfactory handling was done
+ // by the error handler. It's still an exception, the exchange still failed.
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Message exchange has failed so breaking out of routing slip: " + current
+ + " exception: " + current.getException() + " fault: "
+ + current.getFault(false)
+ + (exceptionHandled ? " handled by the error handler" : ""));
+ }
+ break;
+ }
+
}
ExchangeHelper.copyResults(exchange, current);
}
@@ -98,6 +113,10 @@
message.setHeader(header, removeFirstElement(recipients(message)));
}
+ private static boolean hasExceptionBeenHandled(Exchange nextExchange) {
+ return Boolean.TRUE.equals(nextExchange.getProperty(Exchange.EXCEPTION_HANDLED_PROPERTY));
+ }
+
/**
* Returns the outbound message if available. Otherwise return the inbound
* message.
Modified: camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipWithExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipWithExceptionTest.java?rev=886075&r1=886074&r2=886075&view=diff
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipWithExceptionTest.java (original)
+++ camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipWithExceptionTest.java Wed Dec 2 08:53:17 2009
@@ -35,11 +35,13 @@
private MockEndpoint endEndpoint;
private MockEndpoint exceptionEndpoint;
private MockEndpoint exceptionSettingEndpoint;
+ private MockEndpoint aEndpoint;
public void testNoException() throws Exception {
endEndpoint.expectedMessageCount(1);
exceptionEndpoint.expectedMessageCount(0);
-
+ aEndpoint.expectedMessageCount(1);
+
sendRoutingSlipWithNoExceptionThrowingComponent();
assertEndpointsSatisfied();
@@ -48,6 +50,7 @@
public void testWithExceptionThrowingComponentFirstInList() throws Exception {
endEndpoint.expectedMessageCount(0);
exceptionEndpoint.expectedMessageCount(1);
+ aEndpoint.expectedMessageCount(0);
sendRoutingSlipWithExceptionThrowingComponentFirstInList();
@@ -57,6 +60,7 @@
public void testWithExceptionThrowingComponentSecondInList() throws Exception {
endEndpoint.expectedMessageCount(0);
exceptionEndpoint.expectedMessageCount(1);
+ aEndpoint.expectedMessageCount(1);
sendRoutingSlipWithExceptionThrowingComponentSecondInList();
@@ -66,6 +70,7 @@
public void testWithExceptionSettingComponentFirstInList() throws Exception {
endEndpoint.expectedMessageCount(0);
exceptionEndpoint.expectedMessageCount(1);
+ aEndpoint.expectedMessageCount(0);
sendRoutingSlipWithExceptionSettingComponentFirstInList();
@@ -75,6 +80,7 @@
public void testWithExceptionSettingComponentSecondInList() throws Exception {
endEndpoint.expectedMessageCount(0);
exceptionEndpoint.expectedMessageCount(1);
+ aEndpoint.expectedMessageCount(1);
sendRoutingSlipWithExceptionSettingComponentSecondInList();
@@ -82,18 +88,18 @@
}
private void assertEndpointsSatisfied() throws InterruptedException {
- MockEndpoint.assertIsSatisfied(5, TimeUnit.SECONDS, endEndpoint, exceptionEndpoint);
+ MockEndpoint.assertIsSatisfied(5, TimeUnit.SECONDS, endEndpoint, exceptionEndpoint, aEndpoint);
}
protected void sendRoutingSlipWithExceptionThrowingComponentFirstInList() {
template.sendBodyAndHeader("direct:start", ANSWER, ROUTING_SLIP_HEADER,
- "myBean?method=throwException,mock:x");
+ "bean:myBean?method=throwException,mock:a");
}
protected void sendRoutingSlipWithExceptionThrowingComponentSecondInList() {
template.sendBodyAndHeader("direct:start", ANSWER, ROUTING_SLIP_HEADER,
- "mock:a,myBean?method=throwException");
+ "mock:a,bean:myBean?method=throwException");
}
protected void sendRoutingSlipWithNoExceptionThrowingComponent() {
@@ -118,7 +124,8 @@
endEndpoint = resolveMandatoryEndpoint("mock:noexception", MockEndpoint.class);
exceptionEndpoint = resolveMandatoryEndpoint("mock:exception", MockEndpoint.class);
exceptionSettingEndpoint = resolveMandatoryEndpoint("mock:exceptionSetting", MockEndpoint.class);
-
+ aEndpoint = resolveMandatoryEndpoint("mock:a", MockEndpoint.class);
+
exceptionSettingEndpoint.whenAnyExchangeReceived(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.setException(new Exception("Throw me!"));