Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C4D21DFB9 for ; Fri, 14 Sep 2012 09:04:08 +0000 (UTC) Received: (qmail 26570 invoked by uid 500); 14 Sep 2012 09:04:08 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 26513 invoked by uid 500); 14 Sep 2012 09:04:08 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 26484 invoked by uid 99); 14 Sep 2012 09:04:07 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Sep 2012 09:04:07 +0000 Date: Fri, 14 Sep 2012 20:04:07 +1100 (NCT) From: "Claus Ibsen (JIRA)" To: issues@camel.apache.org Message-ID: <1218661495.79568.1347613447773.JavaMail.jiratomcat@arcas> In-Reply-To: <906844246.79144.1347605109145.JavaMail.jiratomcat@arcas> Subject: [jira] [Commented] (CAMEL-5612) Can not define error handler at begin of two route simultaneously MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-5612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13455679#comment-13455679 ] Claus Ibsen commented on CAMEL-5612: ------------------------------------ Yes move the error handler on the route, then its a route scoped error handler. See this page, about the scopes http://camel.apache.org/error-handler.html > Can not define error handler at begin of two route simultaneously > ----------------------------------------------------------------- > > Key: CAMEL-5612 > URL: https://issues.apache.org/jira/browse/CAMEL-5612 > Project: Camel > Issue Type: Bug > Components: camel-core > Affects Versions: 2.9.3 > Reporter: Xiaoli Ding > Assignee: Claus Ibsen > Priority: Minor > Fix For: 2.11.0 > > > i created two route,and i add error handler at begin of two route,the generated code are: > {noformat} > public void configure() throws Exception { > errorHandler(deadLetterChannel("direct:a")) > .from("timer:myTimer1?repeatCount=1").routeId("route1") > .process(new org.apache.camel.Processor() { > public void process(org.apache.camel.Exchange exchange) > throws Exception { > throw new Exception("errorA"); > } > }).id("cProcessor_1"); > errorHandler(deadLetterChannel("direct:b")) > .from("timer:myTimer2?repeatCount=1").routeId("route2") > .process(new org.apache.camel.Processor() { > public void process(org.apache.camel.Exchange exchange) > throws Exception { > throw new Exception("errorB"); > } > }).id("cProcessor_2"); > from("direct:a").routeId("route3") > .process(new org.apache.camel.Processor() { > public void process(org.apache.camel.Exchange exchange) > throws Exception { > Throwable exception = (Throwable) exchange > .getProperty(org.apache.camel.Exchange.EXCEPTION_CAUGHT); > System.out.println("first error:" > + exception.getMessage()); > } > }).id("cProcessor_3"); > from("direct:b").routeId("route4") > .process(new org.apache.camel.Processor() { > public void process(org.apache.camel.Exchange exchange) > throws Exception { > Throwable exception = (Throwable) exchange > .getProperty(org.apache.camel.Exchange.EXCEPTION_CAUGHT); > System.out.println("second error:" > + exception.getMessage()); > } > }).id("cProcessor_4"); > } > {noformat} > when run it,the result is: > {noformat} > Exception in thread "main" java.lang.IllegalArgumentException: errorHandler must be defined before any routes in the RouteBuilder > at org.apache.camel.builder.RouteBuilder.errorHandler(RouteBuilder.java:145) > at org.talend.esb.camel.CamelTester.configure(CamelTester.java:53) > at org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:324) > at org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:278) > at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:264) > at org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:605) > at org.talend.esb.camel.CamelTester.initialize(CamelTester.java:16) > at org.talend.esb.camel.CamelTester.(CamelTester.java:11) > at org.talend.esb.camel.CamelTester.main(CamelTester.java:35) > {noformat} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira