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
commit a41b6ae1491e18e1e0775c06e3abda7c72014f06 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Nov 18 11:46:27 2021 +0100 CAMEL-17206: camel-jbang - Add reload option to enable live reload of routes when updated/saved. --- .../modules/ROOT/pages/camel-jbang.adoc | 24 +++++++++++++++++++++- .../apache/camel/dsl/jbang/core/commands/Run.java | 6 ++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc index b26f7ad..d85cdaa 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc @@ -12,13 +12,22 @@ The CamelJBang supports multiple commands. Running the command below, will print [source,bash] ---- -jbang -Dcamel.jbang.version=3.13.0 CamelJBang@apache/camel [command] +jbang CamelJBang@apache/camel [command] ---- *Note*: the first time you run this command, it may cause dependencies to be cached, therefore taking a few extra seconds to run. All the commands support the `--help` and will display the appropriate help if that flag is provided. +=== Using a specific Camel version + +You can specify which Camel version to run as shown: + +[source,bash] +---- +jbang -Dcamel.jbang.version=3.13.0 CamelJBang@apache/camel [command] +---- + === Search You can use the CLI to search for kamelets, components, languages and miscelaneous components (others). Running the following command will present a list of items that can be searched: @@ -120,6 +129,7 @@ In order to do so, write a YAML-based file with the `route`, the `steps` and the [source,yaml] ---- - route: + id: "hello" from: uri: "kamelet:timer-source" parameters: @@ -143,6 +153,18 @@ jbang -Dcamel.jbang.version=3.13.0 CamelJBang@apache/camel run jms-amqp-10-sink- NOTE: it is necessary to have a AMQP 1.0 broker, such as Apache Artemis, running locally and listening on port 61616. Adjust the route accordingly if using a different address for the broker. +=== Live reload + +You can enable live reload of the route(s) when the source file is updated (saved), +using the `--reload` options as shown: + +[source,bash] +---- +jbang -Dcamel.jbang.version=3.13.0 CamelJBang@apache/camel run jms-amqp-10-sink-binding.yaml --reload +---- + +Then while the Camel application is running, you can update the YAML route and update when saving. + == Installation diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java index b8c3a0b..1330c3f 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java @@ -50,6 +50,9 @@ class Run implements Callable<Integer> { @Option(names = { "--max-messages" }, defaultValue = "0", description = "Max number of messages to process before stopping") private int maxMessages; + @Option(names = { "--reload" }, description = "Enables live reload when source file is changed (saved)") + private boolean reload; + class ShutdownRoute extends RouteBuilder { private File lockFile; @@ -97,6 +100,9 @@ class Run implements Callable<Integer> { } System.setProperty("camel.main.routes-include-pattern", "file:" + binding); + System.setProperty("camel.main.routes-reload-enabled", reload ? "true" : "false"); + System.setProperty("camel.main.routes-reload-directory", "."); + System.setProperty("camel.main.routes-reload-pattern", binding); RuntimeUtil.configureLog(debugLevel);