onException

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

onException

jpcook01
Hello,

I was reading this page: http://camel.apache.org/exception-clause.html

But I'm still not clear if you can have different exception policies for different configure methods in the same route? The different configure methods are reading from different seda queues so it seem from looking at the examples that this would be possible?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: onException

Claus Ibsen-2
On Tue, Oct 13, 2009 at 6:13 PM, jpcook <[hidden email]> wrote:

>
> Hello,
>
> I was reading this page: http://camel.apache.org/exception-clause.html
>
> But I'm still not clear if you can have different exception policies for
> different configure methods in the same route? The different configure
> methods are reading from different seda queues so it seem from looking at
> the examples that this would be possible?
>

What do you mean with different configure methods?

Exception polices is scope based so you can define them
- globally
- per route

Where per route will overrule global.

So you can do

from("seda:foo").onException(MyException.class).maximumRedeliveries(3).to("bean:foo");

from("seda:bar").onException(MyOtherException.class,
MyThridException.class).maximumRedeliveries(2).redeliveryDelay(3000).to("bean:bar");


> Thanks
> --
> View this message in context: http://www.nabble.com/onException-tp25875985p25875985.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|

Re: onException

jpcook01
So I read here that you can do nexted sub route exception handling: Not sure if that is what I want.
http://www.nabble.com/onException-for-a-particular-route-td20702640.html#a20702640

So if I have a my own route builder class extending from RouteBuilder with something like:

        @Override
        public void configure() throws Exception {
                from("seda:start")
        .to("seda:a", "seda:b");
               
                configureResultsA();
                configureResultsB();
        }

private void configureResultsA() throws Exception{
        from("seda:a")
          .process(someprocessing)
          .to("uniqueseda:a");

       from("uniqueseda:a")
           .exception(Exception.class).to("log:UNDELIVERABLE").end()
           .process(somemoreprocessing);        
}

private void configureResultsB() throws Exception{
        from("seda:b")
          .process(someprocessing)
          .to("uniqueseda:b");

       from("uniqueseda:b")          
           .process(somemoreprocessing);        
}

So want to explicitly handle all Exceptions in our own way in configureResultsA() but just have the default behaviour in configureResultsB() where it retries redelivery 5 times or even add some different handling.

I think there is some confusion over what 'per route' is meaning, is that per route builder class or everytime you use from(...) which is was it appears like from the examples.

Hope that makes sense? We are not using Camel 2 yet either.

Thanks

Claus Ibsen-2 wrote
On Tue, Oct 13, 2009 at 6:13 PM, jpcook <jonathan.cook@erars.plus.com> wrote:
>
> Hello,
>
> I was reading this page: http://camel.apache.org/exception-clause.html
>
> But I'm still not clear if you can have different exception policies for
> different configure methods in the same route? The different configure
> methods are reading from different seda queues so it seem from looking at
> the examples that this would be possible?
>

What do you mean with different configure methods?

Exception polices is scope based so you can define them
- globally
- per route

Where per route will overrule global.

So you can do

from("seda:foo").onException(MyException.class).maximumRedeliveries(3).to("bean:foo");

from("seda:bar").onException(MyOtherException.class,
MyThridException.class).maximumRedeliveries(2).redeliveryDelay(3000).to("bean:bar");


> Thanks
> --
> View this message in context: http://www.nabble.com/onException-tp25875985p25875985.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|

Re: onException

Claus Ibsen-2
On Wed, Oct 14, 2009 at 9:54 AM, jpcook <[hidden email]> wrote:

>
> So I read here that you can do nexted sub route exception handling: Not sure
> if that is what I want.
> http://www.nabble.com/onException-for-a-particular-route-td20702640.html#a20702640
>
> So if I have a my own route builder class extending from RouteBuilder with
> something like:
>
>        @Override
>        public void configure() throws Exception {
>                from("seda:start")
>                .to("seda:a", "seda:b");
>
>                configureResultsA();
>                configureResultsB();
>        }
>
> private void configureResultsA() throws Exception{
>        from("seda:a")
>          .process(someprocessing)
>          .to("uniqueseda:a");
>
>       from("uniqueseda:a")
>           .exception(Exception.class).to("log:UNDELIVERABLE").end()
>           .process(somemoreprocessing);
> }
>
> private void configureResultsB() throws Exception{
>        from("seda:b")
>          .process(someprocessing)
>          .to("uniqueseda:b");
>
>       from("uniqueseda:b")
>           .process(somemoreprocessing);
> }
>
> So want to explicitly handle all Exceptions in our own way in
> configureResultsA() but just have the default behaviour in
> configureResultsB() where it retries redelivery 5 times or even add some
> different handling.
>
> I think there is some confusion over what 'per route' is meaning, is that
> per route builder class or everytime you use from(...) which is was it
> appears like from the examples.
>

Yeah its per "from" which is essential an route.

The Java DSL is a bit shorthanded vs. XML. So you just do from() and
its a route.
Where as in XML you have to do

<route>
  <from ...>
   ...
</route>

And you example looks correct to me at first glance.


> Hope that makes sense? We are not using Camel 2 yet either.
>
> Thanks
>
>
> Claus Ibsen-2 wrote:
>>
>> On Tue, Oct 13, 2009 at 6:13 PM, jpcook <[hidden email]>
>> wrote:
>>>
>>> Hello,
>>>
>>> I was reading this page: http://camel.apache.org/exception-clause.html
>>>
>>> But I'm still not clear if you can have different exception policies for
>>> different configure methods in the same route? The different configure
>>> methods are reading from different seda queues so it seem from looking at
>>> the examples that this would be possible?
>>>
>>
>> What do you mean with different configure methods?
>>
>> Exception polices is scope based so you can define them
>> - globally
>> - per route
>>
>> Where per route will overrule global.
>>
>> So you can do
>>
>> from("seda:foo").onException(MyException.class).maximumRedeliveries(3).to("bean:foo");
>>
>> from("seda:bar").onException(MyOtherException.class,
>> MyThridException.class).maximumRedeliveries(2).redeliveryDelay(3000).to("bean:bar");
>>
>>
>>> Thanks
>>> --
>>> View this message in context:
>>> http://www.nabble.com/onException-tp25875985p25875985.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://www.nabble.com/onException-tp25875985p25886803.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus