Hi,

I'm trying to remove and reload rest definitions from xml using camel
2.17.1.  I have the following code to load them (stolen from
camel-spring-boot):

for(String restRoutePath : restRoutePaths) {
           try{
               RestsDefinition rd =
camelContext.loadRestsDefinition(appContext.getResource(restRoutePath).getInputStream());
               camelContext.addRestDefinitions(rd.getRests());
               for(RestDefinition xmlDef : rd.getRests()) {
                   List<RouteDefinition> routeDefs =
xmlDef.asRouteDefinition(camelContext);
                   camelContext.addRouteDefinitions(routeDefs);
                   //Store loaded Routes
                   loadedRouteDefs.addAll(routeDefs);
               }
               } catch(Exception ex){
                   ex.printStackTrace();
               }
           }

To remove the routes I use:
camelContext.removeRouteDefinitions(loadedRouteDefs);

But then when i try to reload the xml again, i get the following error which
makes me think the Rest definitions are not getting completely removed.  It
works fine for regular xml Routes, just not Rest.


org.apache.camel.FailedToStartRouteException: Failed to start route route71
because of duplicate id detected: route75. Please correct ids to be unique
among all your routes.
        at
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:963)
        at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3295)
        at
org.apache.camel.impl.DefaultCamelContext.addRouteDefinitions(DefaultCamelContext.java:908)
        at com.transamerica.isb.api.interfaces.Utils.loadRoutes(Utils.java:90)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)




--
View this message in context: 
http://camel.465427.n5.nabble.com/Removing-and-reloading-Rests-XML-Definitions-dynamically-tp5783724.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to