This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 444da51 CAMEL-16656: camel-core - ResourceReloader SPI - Allow to reload on changes 444da51 is described below commit 444da51885d372088dbdc09ca1964da50a8a672e Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Nov 18 10:16:32 2021 +0100 CAMEL-16656: camel-core - ResourceReloader SPI - Allow to reload on changes --- docs/user-manual/modules/ROOT/nav.adoc | 1 + docs/user-manual/modules/ROOT/pages/dsl.adoc | 1 + docs/user-manual/modules/ROOT/pages/index.adoc | 1 + .../modules/ROOT/pages/route-reload.adoc | 60 ++++++++++++++++++++++ 4 files changed, 63 insertions(+) diff --git a/docs/user-manual/modules/ROOT/nav.adoc b/docs/user-manual/modules/ROOT/nav.adoc index d6a1623..68090ff 100644 --- a/docs/user-manual/modules/ROOT/nav.adoc +++ b/docs/user-manual/modules/ROOT/nav.adoc @@ -70,6 +70,7 @@ ** xref:route-controller.adoc[RouteController] ** xref:route-policy.adoc[RoutePolicy] ** xref:route-configuration.adoc[RouteConfiguration] +** xref:route-reload.adoc[RouteReload] ** xref:route-template.adoc[RouteTemplate] ** xref:routes.adoc[Routes] ** xref:stream-caching.adoc[Stream caching] diff --git a/docs/user-manual/modules/ROOT/pages/dsl.adoc b/docs/user-manual/modules/ROOT/pages/dsl.adoc index 860284f..2e8d114 100644 --- a/docs/user-manual/modules/ROOT/pages/dsl.adoc +++ b/docs/user-manual/modules/ROOT/pages/dsl.adoc @@ -20,3 +20,4 @@ languages (DSL) as listed below: * xref:lambda-route-builder.adoc[LambdaRouteBuilder] for creating routes using Java lambda style. * xref:Endpoint-dsl.adoc[Endpoint DSL] for creating routes using type-safe Camel endpoints in Java. * xref:route-template.adoc[Route Template] for creating reusable route templates. +* xref:route-reload.adoc[Route Reload] for hot-reloading routes in a running Camel application. diff --git a/docs/user-manual/modules/ROOT/pages/index.adoc b/docs/user-manual/modules/ROOT/pages/index.adoc index 9f0e78f..0ae417b 100644 --- a/docs/user-manual/modules/ROOT/pages/index.adoc +++ b/docs/user-manual/modules/ROOT/pages/index.adoc @@ -97,6 +97,7 @@ For a deeper and better understanding of Apache Camel, an xref:faq:what-is-camel * xref:route-controller.adoc[RouteController] * xref:route-policy.adoc[RoutePolicy] * xref:route-configuration.adoc[RouteConfiguration] +* xref:route-reload.adoc[RouteReload] * xref:route-template.adoc[RouteTemplate] * xref:routes.adoc[Routes] * xref:stream-caching.adoc[Stream caching] diff --git a/docs/user-manual/modules/ROOT/pages/route-reload.adoc b/docs/user-manual/modules/ROOT/pages/route-reload.adoc new file mode 100644 index 0000000..9586cdc --- /dev/null +++ b/docs/user-manual/modules/ROOT/pages/route-reload.adoc @@ -0,0 +1,60 @@ += Route Reload + +The route reload functionality in Camel is capable of watching a directory folder (and its subdirectories) +for file changes, and then automatic trigger reload of the running routes in the Camel application. + +NOTE: You cannot watch for file changes in the Java classpath. It is only possible to watch +for file changes in the file system (i.e. using `file` and not `classpath`). + +== Using route reloading + +The route reloading can be configured in Java or with Spring Boot, Quarkus in the following way: + +[source,java] +---- +CamelContext context = ... + +RouteWatcherReloadStrategy reload = new RouteWatcherReloadStrategy(); +reload.setFolder("myfolder"); + +context.addService(reload); +---- + +And with Camel Quarkus / Camel Main you can configure this in `application.properties:` + +[source,properties] +---- +# turn on route reloading on file changes +camel.main.routes-reload-enabled = true +# the base directory to watch +camel.main.routes-reload-directory = myfolder +# pattern(s) for files to watch +camel.main.routes-reload-pattern = routes/*.xml +---- + +And in Spring Boot: + +[source,properties] +---- +# turn on route reloading on file changes +camel.springboot.routes-reload-enabled = true +# the base directory to watch +camel.springboot.routes-reload-directory = myfolder +# pattern(s) for files to watch +camel.springboot.routes-reload-pattern = routes/*.xml +---- + +=== Must use route id's + +When using route reload then you *SHOULD* assign id's to your routes, so Camel +know exactly which routes have been updated. This is necessary because Camel +must stop the existing routes from running, before they can be updated. + +Adding new routes is therefore possible as they would have a new unique route id specified. + +== See Also + +See the following examples that comes with live reloading enabled: + +- https://github.com/apache/camel-examples/tree/master/examples/main-xml[camel-example-main-xml] +- https://github.com/apache/camel-examples/tree/master/examples/main-yaml[camel-example-main-yaml]