You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by RobinAllen <ro...@gmail.com> on 2015/11/14 21:33:04 UTC
2.16.0 breaks my doTry/doCatch around AggregatorStrategy
The test example below works in 2.15.4, but fails in 2.16.0.
In 2.15.4, an exception thrown from an AggregationStrategy bubbles up into
the doTry/doCatch, and is successfully caught.
In 2.16.0, the exception is ignored, and "WARN
org.apache.camel.util.EventHelper - Error notifying event ..." is seen.
A fault in 2.16.0? Or what do I need to change, or how can I rewrite this
pattern to be compliant with 2.16.0?
Many thanks :-)
public class AggregationRuntimeExceptionRouteBuilder extends RouteBuilder {
private class DodgyAggregationStrategy implements AggregationStrategy {
@Override
public Exchange aggregate(Exchange oldExchange, Exchange
newExchange) {
System.out.println("Aggregating old and new");
throw new RuntimeException("Damn!");
}
}
@Override
public void configure() throws Exception {
from("direct:work")
.split(bodyAs(String.class).tokenize(","), new
DodgyAggregationStrategy())
.parallelProcessing()
.process(exchange -> System.out.println("Hello!"))
.end();
from("direct:go")
.doTry()
.to("direct:work")
.doCatch(Exception.class)
.setBody(simple("Try/Catch caught an Exception:
\"${exception.message}\""))
.end();
}
}
@Configuration
public class AggregationRuntimeExceptionRouteBuilderTestContextConfig
extends SingleRouteCamelConfiguration {
@Bean
public RouteBuilder route() {
return new AggregationRuntimeExceptionRouteBuilder();
}
}
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
classes =
{AggregationRuntimeExceptionRouteBuilderTestContextConfig.class},
loader = AnnotationConfigContextLoader.class)
public class AggregationRuntimeExceptionRouteBuilderTest extends
CamelTestSupport {
@Autowired
protected CamelContext camelContext;
@Test
public void Test() {
Exchange exchange = createExchangeWithBody(camelContext,
"1,2,3,4,5");
camelContext.createProducerTemplate().send("direct:go", exchange);
assertThat(MessageHelper.extractBodyAsString(exchange.getIn()),
equalTo("Try/Catch caught an Exception: \"Damn!\""));
}
}
--
View this message in context: http://camel.465427.n5.nabble.com/2-16-0-breaks-my-doTry-doCatch-around-AggregatorStrategy-tp5773888.html
Sent from the Camel - Users mailing list archive at Nabble.com.