Hi, Ok, thanks! In the future I'm happy to submit pull requests. Just need to get the Camel development environment up and running.
The reason for turning off "remove all routes" was that I was trying to see if it was possible to live reload just the changed route, not all. I created five routes each in its own file, using YAML. I then enabled live reload and by default changing one of the files caused all the routes to reload. Turning off "remove all routes" seemed to give the desired result where only the changed route was reloaded. Thanks again! ti 27. jouluk. 2022 klo 15.03 Claus Ibsen (claus.ib...@gmail.com) kirjoitti: > > Hi > > I have just fixed that to be !route.... so the WARN is only logged when no > custom id has been set. > > On Mon, Dec 26, 2022 at 4:08 PM Claus Ibsen <claus.ib...@gmail.com> wrote: > > > Hi > > > > Ah yeah it should be NOT custom id assigned. > > You are welcome to send a PR > > > > BTW is there a reason you turn off remove all routes? > > > > > > So the code should be like: > > > > if (!route.isCustomId()) { > > > > > > > > On Mon, Dec 26, 2022 at 2:40 PM Mikael Koskinen <mijap...@gmail.com> > > wrote: > > > >> Hi again, > >> > >> I checked the source code of RouteWatcherReloadStrategy from here: > >> > >> https://github.com/apache/camel/blob/00526e77bfa88bc20bcde640487cf7d83629e49d/core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java#L274 > >> > >> To me it looks like the warning "Routes with no id's detected"... is > >> always printed if there are routes with custom ids: > >> > >> for (String id : ids) { > >> Route route = getCamelContext().getRoute(id); > >> if (route.isCustomId()) { > >> sj.add(route.getEndpoint().getEndpointUri()); > >> } > >> } > >> if (sj.length() > 0) { > >> LOG.warn( > >> "Routes with no id's detected. Its > >> recommended to assign route id's to your routes so Camel can reload > >> the routes correctly.\n Unassigned routes:\n {}", > >> sj); > >> } > >> > >> ma 26. jouluk. 2022 klo 15.30 Mikael Koskinen (mijap...@gmail.com) > >> kirjoitti: > >> > > >> > Hey, > >> > > >> > Hmm, I'm not sure. The unit test you linked seems to use the "id" > >> > field like I used when defining the route. But the assert uses > >> > "routeId". For example the test: > >> > > >> > when: > >> > loadRoutes ''' > >> > - route: > >> > id: demo-route <---- Here's the "id" field > >> > def "load route inlined camelCase"() { > >> > > >> > But in the assert: > >> > > >> > context.routeDefinitions.size() == 1 > >> > > >> > with(context.routeDefinitions[0], RouteDefinition) { > >> > routeId == 'demo-route' <----- Here's routeId instead of "id" > >> > > >> > But as I previously tested, Karavan uses "id". > >> > > >> > In the first message I posted the log seems to state that "id" is the > >> > way to go as Camel reports when starting the route: > >> > > >> > 2022-12-26 11:28:42.504 INFO 79551 --- [ > >> > main]e.camel.impl.engine.AbstractCamelContext : Started firstRoute > >> > > >> > Where "firstRoute" is the "id". But the problem is that when live > >> > reloading happens, Camel reports that no id has been set. Even though > >> > in the previous line it states that the route with id "firstRoute" has > >> > been started. > >> > > >> > ma 26. jouluk. 2022 klo 14.58 Claus Ibsen (claus.ib...@gmail.com) > >> kirjoitti: > >> > > > >> > > Hi > >> > > > >> > > See some unit tests > >> > > > >> https://github.com/apache/camel/blob/main/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/RoutesTest.groovy#L198 > >> > > > >> > > You can also use Apache Camel Karavan to design yaml routes as it > >> builds > >> > > the YAML correct > >> > > > >> > > > >> > > > >> > > On Mon, Dec 26, 2022 at 12:09 PM Mikael Koskinen <mijap...@gmail.com> > >> wrote: > >> > > > >> > > > Thanks! I tried routeId and route-id but got the following error on > >> both: > >> > > > > >> > > > Unsupported field: routeId > >> > > > in file:timers.yaml, line 2, column 5: > >> > > > routeId: firstRoute > >> > > > ^ > >> > > > > >> > > > at > >> > > > > >> org.apache.camel.dsl.yaml.deserializers.RouteDefinitionDeserializer.setProperties(RouteDefinitionDeserializer.java:128) > >> > > > at > >> > > > > >> org.apache.camel.dsl.yaml.deserializers.RouteDefinitionDeserializer.setProperties(RouteDefinitionDeserializer.java:33) > >> > > > at > >> > > > > >> org.apache.camel.dsl.yaml.common.YamlDeserializerBase.construct(YamlDeserializerBase.java:65) > >> > > > at > >> > > > > >> org.apache.camel.dsl.yaml.common.YamlDeserializationContext$2.construct(YamlDeserializationContext.java:215) > >> > > > > >> > > > This is the route: > >> > > > > >> > > > - route: > >> > > > routeId: firstRoute > >> > > > from: > >> > > > uri: "timer:yaml" > >> > > > parameters: > >> > > > period: "2000" > >> > > > steps: > >> > > > - setBody: > >> > > > constant: "Hello Camel from yaml timer 300" > >> > > > - log: "${body}" > >> > > > > >> > > > If I use Karavan to set the ID of the route, it sets the "id" field: > >> > > > > >> > > > - route: > >> > > > from: > >> > > > uri: timer:yaml > >> > > > steps: > >> > > > - setBody: > >> > > > expression: > >> > > > constant: > >> > > > expression: Hello Camel from yaml timer 300 > >> > > > - log: > >> > > > message: ${body} > >> > > > parameters: > >> > > > period: '2000' > >> > > > id: routeIdFromKaravan > >> > > > > >> > > > > >> > > > ma 26. jouluk. 2022 klo 12.02 Claus Ibsen (claus.ib...@gmail.com) > >> > > > kirjoitti: > >> > > > > > >> > > > > And it can use camelCase too, so routeId or route-id are both > >> possible. > >> > > > > However routeId is recommended so you use same case as XML, Java > >> DSL etc. > >> > > > > > >> > > > > On Mon, Dec 26, 2022 at 11:00 AM Claus Ibsen < > >> claus.ib...@gmail.com> > >> > > > wrote: > >> > > > > > >> > > > > > Hi > >> > > > > > > >> > > > > > Use route-id to set id for routes > >> > > > > > > >> > > > > > > >> > > > > > On Mon, Dec 26, 2022 at 10:38 AM Mikael Koskinen < > >> mijap...@gmail.com> > >> > > > > > wrote: > >> > > > > > > >> > > > > >> Hi, > >> > > > > >> > >> > > > > >> I'm testing how the route reload works if one file has multiple > >> > > > > >> routes. I've defined two routes in a single file and assigned > >> ids to > >> > > > > >> both: > >> > > > > >> > >> > > > > >> - route: > >> > > > > >> id: firstRoute > >> > > > > >> from: > >> > > > > >> uri: "timer:yaml" > >> > > > > >> parameters: > >> > > > > >> period: "2000" > >> > > > > >> steps: > >> > > > > >> - setBody: > >> > > > > >> constant: "Hello Camel from yaml timer 30" > >> > > > > >> - log: "${body}" > >> > > > > >> > >> > > > > >> - route: > >> > > > > >> id: secondRoute > >> > > > > >> from: > >> > > > > >> uri: "timer:yaml" > >> > > > > >> parameters: > >> > > > > >> period: "3000" > >> > > > > >> steps: > >> > > > > >> - setBody: > >> > > > > >> constant: "Hello Camel from yaml timer this one" > >> > > > > >> - log: "${body}" > >> > > > > >> > >> > > > > >> When I run the routes I can see the ids: > >> > > > > >> > >> > > > > >> 2022-12-26 11:28:42.504 INFO 79551 --- [ main] > >> > > > > >> e.camel.impl.engine.AbstractCamelContext : Started > >> firstRoute > >> > > > > >> (timer://yaml) > >> > > > > >> 2022-12-26 11:28:42.504 INFO 79551 --- [ main] > >> > > > > >> e.camel.impl.engine.AbstractCamelContext : Started > >> secondRoute > >> > > > > >> (timer://yaml) > >> > > > > >> > >> > > > > >> Then I've enabled live reload using application.properties with > >> > > > > >> camel.main.routes-reload-remove-all-routes set to false. > >> Here's the > >> > > > > >> full application.properties: > >> > > > > >> > >> > > > > >> # routes to load > >> > > > > >> camel.main.routes-reload-enabled = true > >> > > > > >> camel.main.routes-reload-directory = file:./ > >> > > > > >> camel.main.routes-reload-pattern = *.yaml > >> > > > > >> camel.main.routes-reload-remove-all-routes = false > >> > > > > >> > >> > > > > >> Now when I use Camel Jbang to run the routes: > >> > > > > >> > >> > > > > >> camel run timers.yaml > >> > > > > >> > >> > > > > >> I can see the route ids and the mention that live reload is > >> enabled: > >> > > > > >> > >> > > > > >> 2022-12-26 11:32:03.051 INFO 79751 --- [ main] > >> > > > > >> upport.FileWatcherResourceReloadStrategy : Live route reloading > >> > > > > >> enabled (directory: .) > >> > > > > >> 2022-12-26 11:32:03.073 INFO 79751 --- [ main] > >> > > > > >> e.camel.impl.engine.AbstractCamelContext : Routes startup > >> (started:2) > >> > > > > >> 2022-12-26 11:32:03.073 INFO 79751 --- [ main] > >> > > > > >> e.camel.impl.engine.AbstractCamelContext : Started > >> firstRoute > >> > > > > >> (timer://yaml) > >> > > > > >> 2022-12-26 11:32:03.073 INFO 79751 --- [ main] > >> > > > > >> e.camel.impl.engine.AbstractCamelContext : Started > >> secondRoute > >> > > > > >> (timer://yaml) > >> > > > > >> > >> > > > > >> But when I modify one of the routes in the timers.yaml, I get > >> an > >> > > > > >> warning about missing ids: > >> > > > > >> > >> > > > > >> 2022-12-26 11:33:48.522 INFO 79845 --- [rReloadStrategy] > >> > > > > >> e.camel.impl.engine.AbstractCamelContext : Stopped firstRoute > >> > > > > >> (timer://yaml) > >> > > > > >> 2022-12-26 11:33:48.523 INFO 79845 --- [rReloadStrategy] > >> > > > > >> e.camel.impl.engine.AbstractCamelContext : Shutdown firstRoute > >> > > > > >> (timer://yaml) > >> > > > > >> 2022-12-26 11:33:48.524 INFO 79845 --- [rReloadStrategy] > >> > > > > >> e.camel.impl.engine.AbstractCamelContext : Stopped secondRoute > >> > > > > >> (timer://yaml) > >> > > > > >> 2022-12-26 11:33:48.524 INFO 79845 --- [rReloadStrategy] > >> > > > > >> e.camel.impl.engine.AbstractCamelContext : Shutdown secondRoute > >> > > > > >> (timer://yaml) > >> > > > > >> 2022-12-26 11:33:48.537 INFO 79845 --- [rReloadStrategy] > >> > > > > >> camel.support.RouteWatcherReloadStrategy : Routes reloaded > >> summary > >> > > > > >> (total:2 started:2) > >> > > > > >> 2022-12-26 11:33:48.537 INFO 79845 --- [rReloadStrategy] > >> > > > > >> camel.support.RouteWatcherReloadStrategy : Started > >> firstRoute > >> > > > > >> (timer://yaml) (source: timers.yaml:4) > >> > > > > >> 2022-12-26 11:33:48.537 INFO 79845 --- [rReloadStrategy] > >> > > > > >> camel.support.RouteWatcherReloadStrategy : Started > >> secondRoute > >> > > > > >> (timer://yaml) (source: timers.yaml:15) > >> > > > > >> 2022-12-26 11:33:48.538 WARN 79845 --- [rReloadStrategy] > >> > > > > >> camel.support.RouteWatcherReloadStrategy : Routes with no id's > >> > > > > >> detected. Its recommended to assign route id's to your routes > >> so Camel > >> > > > > >> can reload the routes correctly. > >> > > > > >> Unassigned routes: > >> > > > > >> timer://yaml?period=2000 > >> > > > > >> timer://yaml?period=3000 > >> > > > > >> > >> > > > > >> A bug? > >> > > > > >> > >> > > > > >> Best regards, > >> > > > > >> Mikael > >> > > > > >> > >> > > > > > > >> > > > > > > >> > > > > > -- > >> > > > > > Claus Ibsen > >> > > > > > ----------------- > >> > > > > > @davsclaus > >> > > > > > Camel in Action 2: https://www.manning.com/ibsen2 > >> > > > > > > >> > > > > > >> > > > > > >> > > > > -- > >> > > > > Claus Ibsen > >> > > > > ----------------- > >> > > > > @davsclaus > >> > > > > Camel in Action 2: https://www.manning.com/ibsen2 > >> > > > > >> > > > >> > > > >> > > -- > >> > > Claus Ibsen > >> > > ----------------- > >> > > @davsclaus > >> > > Camel in Action 2: https://www.manning.com/ibsen2 > >> > > > > > > -- > > Claus Ibsen > > ----------------- > > @davsclaus > > Camel in Action 2: https://www.manning.com/ibsen2 > > > > > -- > Claus Ibsen > ----------------- > @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2