You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kalyan <re...@gmail.com> on 2013/05/13 20:00:04 UTC

onException: Global declaration at CamelHttpTransportServlet

When a RouteBuilder defines onException in the following way, is it available
for all RouteBuilders of the same CamelContext ?

RouteBuilder routeBuilder = new RouteBuilder()
{
        @Override
        public void configure()
        {
               
onException(HttpOperationFailedException.class).handled(true)
        .process(new Processor()
        {
            @Override
            public void process(Exchange exchange)
                throws Exception
            {
                //blah
            }
        }).transform().constant("There was an exception");
       
                from("servlet:///test?matchOnUriPrefix=true")
        .to("http://localhost:8080/mywar/sample?bridgeEndpoint=true");
        }
};

However, I would like to know if:
- There is a way to handle 404 error on CamelHttpTransportServlet where the
url pattern is matched but no "servlet:///" is found.
- When there are multiple camel contexts; camelcontext1's router calls
camelcontext2's route and camelcontext2's route had an exception. Can
camelcontext1 see this as an exception (even though it did not happen in its
context) ? What is the best way to handle these scenarios (where there could
be exception propagation between camelcontexts)




--
View this message in context: http://camel.465427.n5.nabble.com/onException-Global-declaration-at-CamelHttpTransportServlet-tp5732428.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: onException: Global declaration at CamelHttpTransportServlet

Posted by kalyan <re...@gmail.com>.
Thank you. So I guess, the same holds good for handling the exceptions in vm,
direct-vm calls.



--
View this message in context: http://camel.465427.n5.nabble.com/onException-Global-declaration-at-CamelHttpTransportServlet-and-bestpractices-tp5732428p5732491.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: onException: Global declaration at CamelHttpTransportServlet

Posted by Claus Ibsen <cl...@gmail.com>.
No you would need to create a base class, and have the onException in
that base class.
And then extend your base class and call super.configure(). (i.e. OO
inheritence) then you can have it for all your routes.

On Mon, May 13, 2013 at 8:00 PM, kalyan <re...@gmail.com> wrote:
> When a RouteBuilder defines onException in the following way, is it available
> for all RouteBuilders of the same CamelContext ?
>
> RouteBuilder routeBuilder = new RouteBuilder()
> {
>         @Override
>         public void configure()
>         {
>
> onException(HttpOperationFailedException.class).handled(true)
>         .process(new Processor()
>         {
>             @Override
>             public void process(Exchange exchange)
>                 throws Exception
>             {
>                 //blah
>             }
>         }).transform().constant("There was an exception");
>
>                 from("servlet:///test?matchOnUriPrefix=true")
>         .to("http://localhost:8080/mywar/sample?bridgeEndpoint=true");
>         }
> };
>
> However, I would like to know if:
> - There is a way to handle 404 error on CamelHttpTransportServlet where the
> url pattern is matched but no "servlet:///" is found.
> - When there are multiple camel contexts; camelcontext1's router calls
> camelcontext2's route and camelcontext2's route had an exception. Can
> camelcontext1 see this as an exception (even though it did not happen in its
> context) ? What is the best way to handle these scenarios (where there could
> be exception propagation between camelcontexts)
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/onException-Global-declaration-at-CamelHttpTransportServlet-tp5732428.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen