Morning All
I'm attempting to simulate errors in order to test my error handling. In my
test class I create the following interception in the createCamelContext
method:
context.addRoutes(new RouteSupport());
RouteDefinition route = context.getRouteDefinition("Route1");
route.adviceWith(context, new RouteBuilder(){
@Override
public void configure() throws Exception{
interceptSendToEndpoint("bean:sqlBuilder?method=makeEntryGeneric")
.skipSendToOriginalEndpoint()
.process(new SimulateDatabaseError());
}
});
Running a test which causes a message to route to
"bean:sqlBuilder?method=makeEntryGeneric" performs correctly; i.e. the
message is intercepted, an exception is thrown and handled as expected (the
test passes).
If I add a 2nd intercept to the above:
route = context.getRouteDefinition("DBContentsInterface");
route.adviceWith(context, new RouteBuilder(){
@Override
public void configure() throws Exception{
interceptSendToEndpoint("bean:sqlBuilder?method=getUpdatedTrackInfo")
.skipSendToOriginalEndpoint()
.process(new SimulateDatabaseError());
}
});
And run the same test, it fails. The exact same message is sent to
"bean:sqlBuilder?method=makeEntryGeneric", this time the message is
intercepted but the exception isn't handled. Any ideas why?
n.b. SimulateDatabaseError() is as follows:
private class SimulateDatabaseError implements Processor {
public void process(Exchange exchange) throws Exception{
System.out.println("Msg intercepted");
throw new
Exception(exchange.getIn().getBody().toString());
}
}
The OnException handler in RouteSupport is as follows:
onException(Exception.class)
.handled(true)
.bean(gduk.irad.DBErrorHandler.class, "errorMessage")
.to("file:target/errors?fileName=Errors.log&fileExist=Append");
Many thanks in advance.
Matt
--
View this message in context:
http://camel.465427.n5.nabble.com/intercept-using-adviceWith-tp4520468p4520468.html
Sent from the Camel - Users mailing list archive at Nabble.com.