You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Xiaoli Ding (JIRA)" <ji...@apache.org> on 2012/09/14 08:45:09 UTC

[jira] [Created] (CAMEL-5612) Can not define error handler at begin of two route simultaneously

Xiaoli Ding created CAMEL-5612:
----------------------------------

             Summary: 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
            Priority: Minor


i created two route,and i add one error handler at begin of route,the generated code are:
{noformat}
	@Override
	public void configure() throws Exception {
		errorHandler(deadLetterChannel("direct:a"))
				.from("timer:myTimer1?repeatCount=1")
				.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")
				.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("toProcessMidRouteLevel_1_cMessagingEndpoint_3")
				.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("toProcessMidRouteLevel_1_cMessagingEndpoint_4")
				.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.<init>(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

[jira] [Comment Edited] (CAMEL-5612) Can not define error handler at begin of two route simultaneously

Posted by "Xiaoli Ding (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-5612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13455685#comment-13455685 ] 

Xiaoli Ding edited comment on CAMEL-5612 at 9/14/12 8:33 PM:
-------------------------------------------------------------

thanks for your fast reply.
yes,i know for this code,it is worked:
--------
		from("timer:myTimer1?repeatCount=1").routeId("route1")
				.errorHandler(deadLetterChannel("direct:a"))
				.process(new org.apache.camel.Processor() {
					public void process(org.apache.camel.Exchange exchange)
							throws Exception {
						throw new Exception("errorA");
					}

				}).id("cProcessor_1");
-------
you mean when i want to let one error handler to controle one route,should code like this?
but i want to know if errorhandler can put before the route when i want it to controle one route?like the code as in bug description.
i can not let one error handler to controle one route by code "errorHandler.from"?
                
      was (Author: xlding):
    thanks for your fast reply.
yes,i know for this code,it is worked:
--------
		from("timer:myTimer1?repeatCount=1").routeId("route1")
				.errorHandler(deadLetterChannel("direct:a"))
				.process(new org.apache.camel.Processor() {
					public void process(org.apache.camel.Exchange exchange)
							throws Exception {
						throw new Exception("errorA");
					}

				}).id("cProcessor_1");
-------
you mean when i want to let one error handler to controle one route,should code like this?
but i want to know if errorhandler can put before the route when i want it to controle one route?
                  
> 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.<init>(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

[jira] [Commented] (CAMEL-5612) Can not define error handler at begin of two route simultaneously

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-5612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13455689#comment-13455689 ] 

Claus Ibsen commented on CAMEL-5612:
------------------------------------

Read the link about the scopes.

If you want a route scoped error handler, then put it in the route.
If you want a context scope error handler, then put it outside routes, and in the top of the configure method (eg before any routes)
                
> 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.<init>(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

[jira] [Commented] (CAMEL-5612) Can not define error handler at begin of two route simultaneously

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ 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.<init>(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

[jira] [Commented] (CAMEL-5612) Can not define error handler at begin of two route simultaneously

Posted by "Xiaoli Ding (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-5612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13455685#comment-13455685 ] 

Xiaoli Ding commented on CAMEL-5612:
------------------------------------

thanks for your fast reply.
yes,i know for this code,it is worked:
		from("timer:myTimer1?repeatCount=1").routeId("route1")
				.errorHandler(deadLetterChannel("direct:a"))
				.process(new org.apache.camel.Processor() {
					public void process(org.apache.camel.Exchange exchange)
							throws Exception {
						throw new Exception("errorA");
					}

				}).id("cProcessor_1");

you mean when i want to let one error handler to controle one route,should code like this?
but i want to know if errorhandler can put before the route when i want it to controle one route?
                
> 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.<init>(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

[jira] [Resolved] (CAMEL-5612) Can not define error handler at begin of two route simultaneously

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-5612?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-5612.
--------------------------------

       Resolution: Not A Problem
    Fix Version/s: 2.11.0
         Assignee: Claus Ibsen

This is working as designed. You must define error handlers *before* any routes, which is what the message in the exception says.

What you have is
- error handler
- route
- error handler
- route
- ...

It should be

- error handler
- error handler
- route
- route
- ...

                
> 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}
> 	@Override
> 	public void configure() throws Exception {
> 		errorHandler(deadLetterChannel("direct:a"))
> 				.from("timer:myTimer1?repeatCount=1")
> 				.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")
> 				.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("toProcessMidRouteLevel_1_cMessagingEndpoint_3")
> 				.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("toProcessMidRouteLevel_1_cMessagingEndpoint_4")
> 				.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.<init>(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

[jira] [Commented] (CAMEL-5612) Can not define error handler at begin of two route simultaneously

Posted by "liugang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-5612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13455692#comment-13455692 ] 

liugang commented on CAMEL-5612:
--------------------------------

So you mean we have only two scope: global and route scope?
but we can have some code like 'errorHandler(defaultErrorHandler()).from("timer:foo")....;', in this case, it's a global scope, not a route scope? if we want to do a route scope errorhandler, we have to put it after "from", right?
Thanks.
                
> 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.<init>(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

[jira] [Updated] (CAMEL-5612) Can not define error handler at begin of two route simultaneously

Posted by "Xiaoli Ding (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-5612?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xiaoli Ding updated CAMEL-5612:
-------------------------------

    Description: 
i created two route,and i add  error handler at begin of two route,the generated code are:
{noformat}
	@Override
	public void configure() throws Exception {
		errorHandler(deadLetterChannel("direct:a"))
				.from("timer:myTimer1?repeatCount=1")
				.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")
				.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("toProcessMidRouteLevel_1_cMessagingEndpoint_3")
				.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("toProcessMidRouteLevel_1_cMessagingEndpoint_4")
				.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.<init>(CamelTester.java:11)
	at org.talend.esb.camel.CamelTester.main(CamelTester.java:35)
{noformat}

  was:
i created two route,and i add one error handler at begin of route,the generated code are:
{noformat}
	@Override
	public void configure() throws Exception {
		errorHandler(deadLetterChannel("direct:a"))
				.from("timer:myTimer1?repeatCount=1")
				.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")
				.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("toProcessMidRouteLevel_1_cMessagingEndpoint_3")
				.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("toProcessMidRouteLevel_1_cMessagingEndpoint_4")
				.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.<init>(CamelTester.java:11)
	at org.talend.esb.camel.CamelTester.main(CamelTester.java:35)
{noformat}

    
> 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
>            Priority: Minor
>
> i created two route,and i add  error handler at begin of two route,the generated code are:
> {noformat}
> 	@Override
> 	public void configure() throws Exception {
> 		errorHandler(deadLetterChannel("direct:a"))
> 				.from("timer:myTimer1?repeatCount=1")
> 				.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")
> 				.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("toProcessMidRouteLevel_1_cMessagingEndpoint_3")
> 				.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("toProcessMidRouteLevel_1_cMessagingEndpoint_4")
> 				.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.<init>(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

[jira] [Updated] (CAMEL-5612) Can not define error handler at begin of two route simultaneously

Posted by "Xiaoli Ding (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-5612?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xiaoli Ding updated CAMEL-5612:
-------------------------------

    Description: 
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.<init>(CamelTester.java:11)
	at org.talend.esb.camel.CamelTester.main(CamelTester.java:35)
{noformat}

  was:
i created two route,and i add  error handler at begin of two route,the generated code are:
{noformat}
	@Override
	public void configure() throws Exception {
		errorHandler(deadLetterChannel("direct:a"))
				.from("timer:myTimer1?repeatCount=1")
				.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")
				.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("toProcessMidRouteLevel_1_cMessagingEndpoint_3")
				.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("toProcessMidRouteLevel_1_cMessagingEndpoint_4")
				.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.<init>(CamelTester.java:11)
	at org.talend.esb.camel.CamelTester.main(CamelTester.java:35)
{noformat}

    
> 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.<init>(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

[jira] [Comment Edited] (CAMEL-5612) Can not define error handler at begin of two route simultaneously

Posted by "Xiaoli Ding (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-5612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13455685#comment-13455685 ] 

Xiaoli Ding edited comment on CAMEL-5612 at 9/14/12 8:26 PM:
-------------------------------------------------------------

thanks for your fast reply.
yes,i know for this code,it is worked:
--------
		from("timer:myTimer1?repeatCount=1").routeId("route1")
				.errorHandler(deadLetterChannel("direct:a"))
				.process(new org.apache.camel.Processor() {
					public void process(org.apache.camel.Exchange exchange)
							throws Exception {
						throw new Exception("errorA");
					}

				}).id("cProcessor_1");
-------
you mean when i want to let one error handler to controle one route,should code like this?
but i want to know if errorhandler can put before the route when i want it to controle one route?
                
      was (Author: xlding):
    thanks for your fast reply.
yes,i know for this code,it is worked:
		from("timer:myTimer1?repeatCount=1").routeId("route1")
				.errorHandler(deadLetterChannel("direct:a"))
				.process(new org.apache.camel.Processor() {
					public void process(org.apache.camel.Exchange exchange)
							throws Exception {
						throw new Exception("errorA");
					}

				}).id("cProcessor_1");

you mean when i want to let one error handler to controle one route,should code like this?
but i want to know if errorhandler can put before the route when i want it to controle one route?
                  
> 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.<init>(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

[jira] [Commented] (CAMEL-5612) Can not define error handler at begin of two route simultaneously

Posted by "Xiaoli Ding (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-5612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13455678#comment-13455678 ] 

Xiaoli Ding commented on CAMEL-5612:
------------------------------------

thanks.
but now i want the first error handler only deal with "route1",and second error handler only deal with "route2",it is possible by this order?

error handler
error handler
route1
route2
route3
route4

thanks for reply!
                
> 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.<init>(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