Hi, I spotted somewhat surprising behavior when configuring route builder via groovy script. If the route builder does not have onException clause, I can assign route ID to each of the configured routes. This route IDs will stay intact when I invoke context.getRouteDefinition("routeID"). However, if onException clause is introduced into the route builder, the IDs will not be preserved. Instead, Camel will change the IDs with default route ID (route1, route2, ...). I tested on 2.10.2 and 2.10.3 and the behaviors are the same for those versions.
Is this by design or a bug? I enclose the code to reproduce the behavior below (will attach whole test project if necessary): 1. Case 1: OnException is absent *WithoutOnExceptionRouteBuilder.groovy -------------------------------------------------------------- class WithoutOnExceptionRouteBuilder extends SpringRouteBuilder { @Override void configure() throws Exception { from('direct:nodeA') .id('nodeA') .to('direct:nodeB') from('direct:nodeB') .id('nodeB') .to('mock:resultB') } } *TestRouteWithoutOnException.java ----------------------------------------------------------- public class TestRouteWithoutOnException extends CamelSpringTestSupport { @Override protected AbstractApplicationContext createApplicationContext() { return new ClassPathXmlApplicationContext("without-onexception-context.xml"); } @Test public void testRouteWithoutOnException() throws Exception { RouteDefinition routeA = context.getRouteDefinition("nodeA"); assertNotNull(routeA); RouteDefinition routeB = context.getRouteDefinition("nodeB"); assertNotNull(routeB); } } 2. Case 2: OnException is present OnExceptionrouteBuilder.groovy ----------------------------------------------- class OnExceptionRouteBuilder extends SpringRouteBuilder { @Override void configure() throws Exception { onException(Exception.class) .handled(true) .log('Error occured') from('direct:nodeA') .id('nodeA') .to('direct:nodeB') from('direct:nodeB') .id('nodeB') .to('mock:resultB') } } TestRouteWithOnException.java ------------------------------------------------ public class TestRouteWithOnException extends CamelSpringTestSupport { @Override protected AbstractApplicationContext createApplicationContext() { return new ClassPathXmlApplicationContext("onexception-context.xml"); } @Test public void testRouteWithOnException() throws Exception { RouteDefinition routeA = context.getRouteDefinition("nodeA"); assertNotNull(routeA); RouteDefinition routeB = context.getRouteDefinition("nodeB"); assertNotNull(routeB); } @Test public void testRouteWithOnExceptionDefaultId() throws Exception { RouteDefinition routeA = context.getRouteDefinition("route1"); assertNotNull(routeA); RouteDefinition routeB = context.getRouteDefinition("route2"); assertNotNull(routeB); } } Regards, Mike