You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by leon <it...@gmail.com> on 2014/10/07 12:04:25 UTC
Can exception clause works with rest dsl in camel 2.14.0?
Hi all,
I am using camel 2.14.0 and the new rest dsl feature. It seems exception
clause is not working with rest dsl. Am I doing anything wrong? Here are my
classes:
public MyRouteBuilder extends RouteBuilder {
public void configure() throws Exception {
restConfiguration.component("servlet").bindingMode(RestBindingMode.json);
onException(RuntimeException.class).process(new
MyProcessor()).stop();
rest("/test")
.get("/error")
.route()
.bean(MyClassRaiseException.class, "test");
}
}
public MyClassRaiseException {
public void test() {
throws new RuntimeException("TEST");
}
}
public MyProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
System.out.println("This line of code is not called");
}
}
MyProcessor is not get called. Helps are needed please!!
Kind regards,
Leon Chang
--
View this message in context: http://camel.465427.n5.nabble.com/Can-exception-clause-works-with-rest-dsl-in-camel-2-14-0-tp5757381.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Can exception clause works with rest dsl in camel 2.14.0?
Posted by Dewitte P-Alban <de...@gmail.com>.
Hi, It is not working gloably but for each route it works if you describe a
onException clause.
A working example :
rest(...)
.post("/{CamelMongoDbCollection}").description("Save operation")
.route()
.process(new MRCProcessor())
.to(String.format(mongoDBRoute, MongoDbOperation.insert))
.process(new MRCOutProcessor())
.onException(CamelMongoDbException.class).handled(true).process(new
MRCErrorProcessor())
.endRest()
Best regards
On Sat, Oct 25, 2014 at 1:18 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> Yeah I think unfortunately that onException, and interceptor etc isnt
> supported in nested routes with the rest dsl. We will get this fixed
> in the next patch release. I logged a ticket
> https://issues.apache.org/jira/browse/CAMEL-7959
>
> On Tue, Oct 7, 2014 at 12:04 PM, leon <it...@gmail.com> wrote:
> > Hi all,
> >
> > I am using camel 2.14.0 and the new rest dsl feature. It seems exception
> > clause is not working with rest dsl. Am I doing anything wrong? Here are
> my
> > classes:
> >
> > public MyRouteBuilder extends RouteBuilder {
> > public void configure() throws Exception {
> >
> > restConfiguration.component("servlet").bindingMode(RestBindingMode.json);
> > onException(RuntimeException.class).process(new
> > MyProcessor()).stop();
> > rest("/test")
> > .get("/error")
> > .route()
> > .bean(MyClassRaiseException.class, "test");
> > }
> > }
> >
> > public MyClassRaiseException {
> > public void test() {
> > throws new RuntimeException("TEST");
> > }
> > }
> >
> > public MyProcessor implements Processor {
> > public void process(Exchange exchange) throws Exception {
> > System.out.println("This line of code is not called");
> > }
> > }
> >
> > MyProcessor is not get called. Helps are needed please!!
> >
> > Kind regards,
> > Leon Chang
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Can-exception-clause-works-with-rest-dsl-in-camel-2-14-0-tp5757381.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/
>
Re: Can exception clause works with rest dsl in camel 2.14.0?
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Yeah I think unfortunately that onException, and interceptor etc isnt
supported in nested routes with the rest dsl. We will get this fixed
in the next patch release. I logged a ticket
https://issues.apache.org/jira/browse/CAMEL-7959
On Tue, Oct 7, 2014 at 12:04 PM, leon <it...@gmail.com> wrote:
> Hi all,
>
> I am using camel 2.14.0 and the new rest dsl feature. It seems exception
> clause is not working with rest dsl. Am I doing anything wrong? Here are my
> classes:
>
> public MyRouteBuilder extends RouteBuilder {
> public void configure() throws Exception {
>
> restConfiguration.component("servlet").bindingMode(RestBindingMode.json);
> onException(RuntimeException.class).process(new
> MyProcessor()).stop();
> rest("/test")
> .get("/error")
> .route()
> .bean(MyClassRaiseException.class, "test");
> }
> }
>
> public MyClassRaiseException {
> public void test() {
> throws new RuntimeException("TEST");
> }
> }
>
> public MyProcessor implements Processor {
> public void process(Exchange exchange) throws Exception {
> System.out.println("This line of code is not called");
> }
> }
>
> MyProcessor is not get called. Helps are needed please!!
>
> Kind regards,
> Leon Chang
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Can-exception-clause-works-with-rest-dsl-in-camel-2-14-0-tp5757381.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/