Hi What version of Camel are you using?
On Fri, Jun 24, 2011 at 11:36 AM, woggle23 <[email protected]> wrote: > 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. > -- Claus Ibsen ----------------- FuseSource Email: [email protected] Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/
