You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/12/01 10:19:43 UTC

[camel] branch main updated (f594dcf -> 877963c)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from f594dcf  Resync
     new 2ccdcd5  CAMEL-17212: camel-jbang - Run goal can run any Camel file.
     new 877963c  CAMEL-17212: camel-jbang - Run goal can run any Camel file.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../modules/ROOT/pages/camel-jbang.adoc            | 158 ++++++++++-----------
 dsl/camel-jbang/camel-jbang-core/pom.xml           |  11 +-
 .../apache/camel/dsl/jbang/core/commands/Run.java  |  20 +--
 dsl/camel-jbang/camel-jbang-main/pom.xml           |   2 +
 4 files changed, 101 insertions(+), 90 deletions(-)

[camel] 01/02: CAMEL-17212: camel-jbang - Run goal can run any Camel file.

Posted by da...@apache.org.
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 2ccdcd521c9387ad5c96df1003573c0c64389c31
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Dec 1 11:15:19 2021 +0100

    CAMEL-17212: camel-jbang - Run goal can run any Camel file.
---
 .../modules/ROOT/pages/camel-jbang.adoc            | 158 ++++++++++-----------
 .../apache/camel/dsl/jbang/core/commands/Run.java  |  20 +--
 2 files changed, 89 insertions(+), 89 deletions(-)

diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
index 0f16071..0590f54 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
@@ -1,10 +1,17 @@
 = Camel JBang
 
-A JBang-based Camel app for searching for kamelets, components, languages, running routes.
+A JBang-based Camel app for easily running Camel routes.
 
 The `camel-jbang` is available from *Camel 3.12* and newer versions.
 
-When running Camel JBang, it is possible to set the Camel version to use. For instance, to run the commands with the version 3.14.0, define the `camel.jbang.version` property in the command line.
+== Installation
+
+It is not necessary to install Camel JBang. However, if you prefer to do so, JBang makes it easy for us by providing an installation feature that works with Github. If you have JBang installed on your system, then you can run the following command to install CamelJBang:
+
+[source,bash]
+----
+jbang app install CamelJBang@apache/camel
+----
 
 == Using Camel JBang
 
@@ -28,9 +35,78 @@ You can specify which Camel version to run as shown:
 jbang -Dcamel.jbang.version=3.14.0 CamelJBang@apache/camel [command]
 ----
 
+== Running Routes
+
+You can run Camel routes from any of the supported DSLs in Camel such as YAML, XML, Java, Groovy.
+
+For example to run YAML-based routes which also refer to Kamelets in the catalog.
+In order to do so, write a YAML-based file with the `route`, the `steps` and the `to` destination for the route. The following example, shows a route that uses the Timer Source Kamelet to produce messages every second. The body of the messages will be logged to the standard output. Subsequently, they will be sent to a AMQP 1.0 compliant broker using the JMS AMQ 1.0 Sink Kamelet.
+
+[source,yaml]
+----
+- route:
+    id: "hello"
+    from:
+      uri: "kamelet:timer-source"
+      parameters:
+        period: 1000
+        message: "Hello Camel JBang"
+    steps:
+      - log: "${body}"
+      - to:
+          uri: "kamelet:jms-amqp-10-sink"
+          parameters:
+            remoteURI: amqp://localhost:61616
+            destinationName: test-queue
+----
+
+Execute the following command to run this route:
+
+[source,bash]
+----
+jbang -Dcamel.jbang.version=3.14.0 CamelJBang@apache/camel run jms-amqp-10-sink-binding.yaml
+----
+
+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.14.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.
+
+NOTE: The live reload is meant for development purposes, and if you encounter problems with reloading
+such as JVM class loading issues, then you may need to restart the application.
+
+=== Running routes hosted on GitHub
+
+You can run a route that is hosted on GitHub using Camels xref:components:others:resourceresolver-github.adoc[github] resource loader.
+
+For example to run one of the Camel K examples you can do:
+
+[source,bash]
+----
+jbang -Dcamel.jbang.version=3.14.0 CamelJBang@apache/camel run run github:apache:camel-k:examples/languages/routes.yaml
+----
+
+=== Running local Kamelets
+
+You can also use Camel JBang to try local Kamelets, without the need to publish them on Github or package them in a jar.
+
+[source,bash]
+----
+jbang -Dcamel.jbang.version=3.14.0 CamelJBang@apache/camel run --local-kamelet-dir=/path/to/local/kamelets earthquake.yaml
+----
+
 === 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:
+You can use the CLI to search for kamelets, components, languages and miscellaneous components (others). Running the following command will present a list of items that can be searched:
 
 [source,bash]
 ----
@@ -118,79 +194,3 @@ You can also generate bindings that can be run by CamelJBang or Camel Core, but
 ----
 jbang -Dcamel.jbang.version=3.14.0 CamelJBang@apache/camel init binding --destination /path/to/destination/directory/ --kamelet sftp-source --project core
 ----
-
-
-== Running Routes
-
-At the moment it is possible to run YAML-based routes which also refer to Kamelets in the catalog.
-
-In order to do so, write a YAML-based file with the `route`, the `steps` and the `to` destination for the route. The following example, shows a route that uses the Timer Source Kamelet to produce messages every second. The body of the messages will be logged to the standard output. Subsequently, they will be sent to a AMQP 1.0 compliant broker using the JMS AMQ 1.0 Sink Kamelet.
-
-[source,yaml]
-----
-- route:
-    id: "hello"
-    from:
-      uri: "kamelet:timer-source"
-      parameters:
-        period: 1000
-        message: "Hello Camel JBang"
-    steps:
-      - log: "${body}"
-      - to:
-          uri: "kamelet:jms-amqp-10-sink"
-          parameters:
-            remoteURI: amqp://localhost:61616
-            destinationName: test-queue
-----
-
-Execute the following command to run this route:
-
-[source,bash]
-----
-jbang -Dcamel.jbang.version=3.14.0 CamelJBang@apache/camel run jms-amqp-10-sink-binding.yaml
-----
-
-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.14.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.
-
-=== Running routes hosted on GitHub
-
-You can run a route that is hosted on GitHub using Camels xref:components:others:resourceresolver-github.adoc[github] resource loader.
-
-For example to run one of the Camel K examples you can do:
-
-[source,bash]
-----
-jbang -Dcamel.jbang.version=3.14.0 CamelJBang@apache/camel run run github:apache:camel-k:examples/languages/routes.yaml
-----
-
-=== Running local Kamelets
-
-You can also use Camel JBang to try local Kamelets, without the need to publish them on Github or package them in a jar.
-
-[source,bash]
-----
-jbang -Dcamel.jbang.version=3.14.0 CamelJBang@apache/camel run --local-kamelet-dir=/path/to/local/kamelets earthquake.yaml
-----
-
-
-== Installation
-
-It is not necessary to install Camel JBang. However, if you prefer to do so, JBang makes it easy for us by providing an installation feature that works with Github. If you have JBang installed on your system, then you can run the following command to install CamelJBang:
-
-[source,bash]
-----
-jbang app install CamelJBang@apache/camel
-----
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 35ee8f8..ad98c01 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
@@ -38,8 +38,8 @@ class Run implements Callable<Integer> {
     private File lockFile;
     private ScheduledExecutorService executor;
 
-    @Parameters(description = "The path to the kamelet binding", arity = "0..1")
-    private String binding;
+    @Parameters(description = "The Camel file to run", arity = "0..1")
+    private String file;
 
     //CHECKSTYLE:OFF
     @Option(names = { "-h", "--help" }, usageHelp = true, description = "Display the help and sub-commands")
@@ -150,16 +150,16 @@ class Run implements Callable<Integer> {
             }, 1000, 1000, TimeUnit.MILLISECONDS);
         }
 
-        if (!ResourceHelper.hasScheme(binding) && !binding.startsWith("github:")) {
-            binding = "file:" + binding;
+        if (!ResourceHelper.hasScheme(file) && !file.startsWith("github:")) {
+            file = "file:" + file;
         }
-        main.addInitialProperty("camel.main.routesIncludePattern", binding);
+        main.addInitialProperty("camel.main.routesIncludePattern", file);
 
-        if (binding.startsWith("file:")) {
+        if (file.startsWith("file:")) {
             // check if file exist
-            File bindingFile = new File(binding.substring(5));
-            if (!bindingFile.exists() && !bindingFile.isFile()) {
-                System.err.println("The binding file does not exist");
+            File inputFile = new File(file.substring(5));
+            if (!inputFile.exists() && !inputFile.isFile()) {
+                System.err.println("File does not exist: " + file);
                 return 1;
             }
 
@@ -168,7 +168,7 @@ class Run implements Callable<Integer> {
                 main.addInitialProperty("camel.main.routesReloadEnabled", "true");
                 main.addInitialProperty("camel.main.routesReloadDirectory", ".");
                 // skip file: as prefix
-                main.addInitialProperty("camel.main.routesReloadPattern", binding.substring(5));
+                main.addInitialProperty("camel.main.routesReloadPattern", file.substring(5));
                 // do not shutdown the JVM but stop routes when max duration is triggered
                 main.addInitialProperty("camel.main.durationMaxAction", "stop");
             }

[camel] 02/02: CAMEL-17212: camel-jbang - Run goal can run any Camel file.

Posted by da...@apache.org.
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 877963c13fe795bb768891db0264e275c3dd5bcf
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Dec 1 11:18:42 2021 +0100

    CAMEL-17212: camel-jbang - Run goal can run any Camel file.
---
 docs/user-manual/modules/ROOT/pages/camel-jbang.adoc |  2 +-
 dsl/camel-jbang/camel-jbang-core/pom.xml             | 11 ++++++++++-
 dsl/camel-jbang/camel-jbang-main/pom.xml             |  2 ++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
index 0590f54..7347357 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
@@ -37,7 +37,7 @@ jbang -Dcamel.jbang.version=3.14.0 CamelJBang@apache/camel [command]
 
 == Running Routes
 
-You can run Camel routes from any of the supported DSLs in Camel such as YAML, XML, Java, Groovy.
+You can run Camel routes from any of the supported xref:dsl.adoc[DSLs] in Camel such as YAML, XML, Java, Groovy.
 
 For example to run YAML-based routes which also refer to Kamelets in the catalog.
 In order to do so, write a YAML-based file with the `route`, the `steps` and the `to` destination for the route. The following example, shows a route that uses the Timer Source Kamelet to produce messages every second. The body of the messages will be logged to the standard output. Subsequently, they will be sent to a AMQP 1.0 compliant broker using the JMS AMQ 1.0 Sink Kamelet.
diff --git a/dsl/camel-jbang/camel-jbang-core/pom.xml b/dsl/camel-jbang/camel-jbang-core/pom.xml
index 43642e4..b6c6946 100644
--- a/dsl/camel-jbang/camel-jbang-core/pom.xml
+++ b/dsl/camel-jbang/camel-jbang-core/pom.xml
@@ -18,16 +18,25 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
     <parent>
         <groupId>org.apache.camel</groupId>
         <artifactId>camel-jbang-parent</artifactId>
         <version>3.14.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
-    <modelVersion>4.0.0</modelVersion>
 
     <artifactId>camel-jbang-core</artifactId>
+    <packaging>jar</packaging>
+
     <name>Camel :: JBang :: Core</name>
+    <description>Camel JBang Core</description>
+
+    <properties>
+        <supportLevel>Experimental</supportLevel>
+    </properties>
 
     <dependencies>
         <dependency>
diff --git a/dsl/camel-jbang/camel-jbang-main/pom.xml b/dsl/camel-jbang/camel-jbang-main/pom.xml
index a7d868b..7b014fa 100644
--- a/dsl/camel-jbang/camel-jbang-main/pom.xml
+++ b/dsl/camel-jbang/camel-jbang-main/pom.xml
@@ -19,6 +19,7 @@
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
@@ -35,6 +36,7 @@
     <description>Camel JBang</description>
 
     <properties>
+        <supportLevel>Experimental</supportLevel>
         <checkstyle.skip>true</checkstyle.skip>
         <dist.dir>dist</dist.dir>
     </properties>