camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: global onException handler with different route builders
Date Wed, 25 Nov 2009 10:41:58 GMT
On Wed, Nov 25, 2009 at 11:29 AM, eirilwan <eirilwan@gmail.com> wrote:
>
> Not me. But thanks :)

Sorry so many names on the mailing list.


> I'll try to look into this. This worked flawless until 2.0.0
>

Yeah please do. We love contributions.




>  - eirik
>
>
> Claus Ibsen-2 wrote:
>>
>> On Wed, Nov 25, 2009 at 11:13 AM, eirilwan <eirilwan@gmail.com> wrote:
>>>
>>> Hi
>>>
>>> This still seems to be an issue.
>>>
>>> The exception thrown in FaultRoute does not seem to get caught by
>>> onException defined in BaseRoute. Is there a flag you need to set to make
>>> onException catch exception across route builders?
>>
>> Haven't I told you before that it does not work across route builders.
>> (or was that someone else?)
>> There is a ticket about this (something about template routes)
>>
>>
>>>
>>>  - 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-tp26509205p26510277.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-tp26509205p26510474.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

Mime
View raw message