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 812b4b95f50 CAMEL-18267: ContextReloadStrategy to reload all routes 
after external changes such as properties/vault updated.
812b4b95f50 is described below

commit 812b4b95f50d7ceeb15d4a28f364bd9bbd1a51fd
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Thu Sep 1 17:28:39 2022 +0200

    CAMEL-18267: ContextReloadStrategy to reload all routes after external 
changes such as properties/vault updated.
---
 docs/user-manual/modules/ROOT/nav.adoc             |  1 +
 .../modules/ROOT/pages/context-reload.adoc         | 65 ++++++++++++++++++++++
 docs/user-manual/modules/ROOT/pages/index.adoc     |  1 +
 .../modules/ROOT/pages/route-reload.adoc           |  4 ++
 4 files changed, 71 insertions(+)

diff --git a/docs/user-manual/modules/ROOT/nav.adoc 
b/docs/user-manual/modules/ROOT/nav.adoc
index 659a611d8c2..b4799a478de 100644
--- a/docs/user-manual/modules/ROOT/nav.adoc
+++ b/docs/user-manual/modules/ROOT/nav.adoc
@@ -73,6 +73,7 @@
 ** xref:route-controller.adoc[RouteController]
 ** xref:route-policy.adoc[RoutePolicy]
 ** xref:route-configuration.adoc[RouteConfiguration]
+** xref:context-reload.adoc[ContextReload]
 ** xref:route-reload.adoc[RouteReload]
 ** xref:route-template.adoc[RouteTemplate]
 ** xref:routes.adoc[Routes]
diff --git a/docs/user-manual/modules/ROOT/pages/context-reload.adoc 
b/docs/user-manual/modules/ROOT/pages/context-reload.adoc
new file mode 100644
index 00000000000..44b242d077b
--- /dev/null
+++ b/docs/user-manual/modules/ROOT/pages/context-reload.adoc
@@ -0,0 +1,65 @@
+= Context Reload
+
+The context reload functionality in Camel is capable of reloading all existing 
routes and property placeholders,
+upon an external triggered event.
+
+For example if you are using 
xref:components::aws-secrets-manager-component.adoc[AWS Secrets] then
+enabling context-reload would then reload Camel routes upon a secret is 
updated in AWS.
+
+The context reload is limited to refresh the following on reload:
+
+- xref:using-propertyplaceholder.adoc[property placeholders]
+- every existing xref:routes.adoc[routes] (no changes to structure of routes; 
see xref:route-reload.adoc[]])
+
+General services in xref:camelcontext.adoc[CamelContext] and java beans or 
Camel xref:processor.adoc[] is not updated.
+
+== Using context reloading
+
+The context reloading can be configured in Java or with Spring Boot, Quarkus 
in the following way:
+
+[source,java]
+----
+CamelContext context = ...
+
+ContextReloadStrategy reload = new DefaultContextReloadStrategy();
+context.addService(reload);
+----
+
+And with Camel Quarkus / Camel Main you can configure this in 
`application.properties:`
+
+[source,properties]
+----
+# turn on context reloading
+camel.main.context-reload-enabled = true
+----
+
+And in Spring Boot:
+
+[source,properties]
+----
+# turn on context reloading
+camel.springboot.context-reload-enabled = true
+----
+
+== Triggering context reloading
+
+Any custom code can trigger context reloading. This is done by ensuring the 
context reload is enabled (see above), and
+then from Java you can get hold of `ContextReloadStrategy` as follows:
+
+[source,java]
+----
+ContextReloadStrategy reload = context.hasService(ContextReloadStrategy.class);
+if (reload != null) {
+    // trigger reload
+    reload.onReload(this);
+}
+----
+
+The method `onReload` will then reload all the 
xref:using-propertyplaceholder.adoc[property placeholders] and
+then afterwards reload all existing xref:routes.adoc[routes].
+
+
+== See Also
+
+See related xref:route-reload.adoc[].
+
diff --git a/docs/user-manual/modules/ROOT/pages/index.adoc 
b/docs/user-manual/modules/ROOT/pages/index.adoc
index 0ae417b3040..a3ebb6fdcb6 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:context-reload.adoc[ContextReload]
 * xref:route-reload.adoc[RouteReload]
 * xref:route-template.adoc[RouteTemplate]
 * xref:routes.adoc[Routes]
diff --git a/docs/user-manual/modules/ROOT/pages/route-reload.adoc 
b/docs/user-manual/modules/ROOT/pages/route-reload.adoc
index 4658e28aab9..99ddfe9b154 100644
--- a/docs/user-manual/modules/ROOT/pages/route-reload.adoc
+++ b/docs/user-manual/modules/ROOT/pages/route-reload.adoc
@@ -9,6 +9,8 @@ NOTE: This feature is not supported when using Camel Quarkus, 
as you should be u
 the hot-reloading functionality that comes with Quarkus instead. This 
functionality
 can also reload Java source code changes and much more.
 
+TIP: See related xref:context-reload.adoc[]
+
 == Using route reloading
 
 You cannot watch for file changes in the Java classpath. It is only possible 
to watch
@@ -76,6 +78,8 @@ And adding new routes is therefore possible as they would 
have a new unique rout
 
 == See Also
 
+See related xref:context-reload.adoc[].
+
 See the following examples that comes with live reloading enabled:
 
 - 
https://github.com/apache/camel-examples/tree/main/examples/main-xml[camel-examples/examples/main-xml]

Reply via email to