camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eirilwan <eiril...@gmail.com>
Subject Re: global onException handler with different route builders
Date Wed, 25 Nov 2009 09:09:25 GMT

Hi.. 

Thanks. It works now.  :) When is 2.1 release planned? 

 - Eirik



Claus Ibsen-2 wrote:
> 
> Hi
> 
> Try with 2.1-SNAPSHOT as we have fixed some issues there.
> 
> 
> On Wed, Nov 25, 2009 at 9:46 AM, eirilwan <eirilwan@gmail.com> wrote:
>>
>> Hi
>>
>> I have a problem. I recently upgraded from Camel 2.0-M2 to Camel 2.0.0,
>> which broke some of my integration tests. I have narrowed the problem
>> down
>> to a simple example.
>>
>> I Have 2 routebuilders, BaseRoute and FaultRoute. BaseRoute listens to a
>> direct:start, and sends it forward to direct:thrower which is defined in
>> FaultRoute. In 2.0-M2, errors thrown from FaultRoute got caught by the
>> global onException handler defined in BaseRoute. But in 2.0.0 this
>> exception
>> is not caught, and thrown to the sender. Is the onException clause local
>> within the routebuilder? If so, is it possible to define a global
>> exception
>> handler?
>>
>> The code below contains the example with two tests describing the
>> situation.
>>
>> Regards
>> Eirik L. Wang
>>
>>
>> Example code:
>> @Component("baseRouteBuilder")
>> public class BaseRoute extends RouteBuilder {
>>    @Override
>>    public void configure() throws Exception {
>>        onException(TestCustomException.class).handled(true);
>>
>>        //does not work
>>        from("direct:start").to("direct:thrower");
>>
>>        //Works
>>        from("direct:start2").to("direct:thrower2");
>>        from("direct:thrower2").throwException(new
>> TestCustomException("test"));
>>
>>    }
>> }
>>
>> @Component("faultRouteBuilder")
>> public class FaultRoute extends RouteBuilder{
>>
>>    @Override
>>    public void configure() throws Exception {
>>        from("direct:thrower").throwException(new
>> TestCustomException("message"));
>>    }
>> }
>>
>>
>> Spring-context: applicationContext-camel-routes.xml
>> <context:component-scan base-package="test.routes"/>
>>    <context:annotation-config/>
>>
>>    <!--suppress UnparsedCustomBeanInspection -->
>>    <camel:camelContext id="camel">
>>        <camel:routeBuilder ref="baseRouteBuilder"/>
>>        <camel:routeBuilder ref="faultRouteBuilder"/>
>>    </camel:camelContext>
>>
>>
>> Test:
>>
>> @RunWith(SpringJUnit4ClassRunner.class)
>> @ContextConfiguration(locations =
>> "classpath:applicationContext-camel-routes.xml")
>> public class BaseRouteTest {
>>    @Produce(uri = "direct:start")
>>    protected ProducerTemplate startConsumer;
>>
>>    @Produce(uri = "direct:start2")
>>    protected ProducerTemplate start2Consumer;
>>
>>    @Test
>>    public void shouldCatchExceptionButDoesNot(){
>>        startConsumer.sendBody("test");
>>    }
>>
>>    @Test
>>    public void shouldCatchException(){
>>        start2Consumer.sendBody("test");
>>    }
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/global-onException-handler-with-different-route-builders-tp26509205p26509205.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/global-onException-handler-with-different-route-builders-tp26509205p26509468.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message