Hi,

I had some problems when I tried "endDoTry()" in my RouteBuilder. Here are the 
codes:

              from("timer://myTimer?period=2000").setBody()
                            .simple("Current time is 
${header.firedTime}").doTry()
                            .process(new Processor() {

                                   @Override
                                   public void process(Exchange exchange) 
throws Exception {
                                          throw new Exception("Customized");

                                   }
                            }).setBody(constant("No 
Exception")).to("log:no-error")
                            .to("file://c:/data/input/cFile").endDoTry()
                            .doCatch(Exception.class).to("log:catch");

       }

will cause an Exception:
Exception in thread "main" java.lang.ClassCastException: 
org.apache.camel.model.RouteDefinition cannot be cast to 
org.apache.camel.model.TryDefinition

And even worse, if we add some other routing nodes to Route, for example:

              from("timer://myTimer?period=2000").setBody()
                            .simple("Current time is 
${header.firedTime}").doTry()
                            .process(new Processor() {

                                   @Override
                                   public void process(Exchange exchange) 
throws Exception {
                                          throw new Exception("Customized");

                                   }
                            }).setBody(constant("No 
Exception")).to("log:no-error")
                            
.loadBalance().random().to("log:load1").to("log:load1")
                            .to("file://c:/data/input/cFile").endDoTry()
                            .doCatch(Exception.class).to("log:catch");

       }
after loadBalance(), there will be no exception.

I believe it's a camel bug, and here is similar bug 
https://issues.apache.org/jira/browse/CAMEL-4517 with endChoice().

My question is: will camel fix this problem to make sure it's OK to use 
endDoTry() in all cases?

Best Regards
Xiaopeng Li

Reply via email to