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/02/06 15:29:29 UTC

[camel-examples] branch master updated (78685c4 -> 3494a3b)

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

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


    from 78685c4  CAMEL-16080: Kamelet example
     new d1b8cfc  add routes loader java example
     new 3494a3b  Regen

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:
 examples/README.adoc                               | 10 +++++---
 .../pom.xml                                        | 17 ++++++++-----
 examples/camel-example-routeloader/readme.adoc     | 29 ++++++++++++++++++++++
 .../org/apache/camel/example/MyApplication.java    |  7 +++---
 .../src/main/resources/application.properties      |  7 +++---
 .../src/main/resources/logback.xml                 |  0
 .../main/resources/myroutes/MyRouteBuilder.java    | 17 +++++++++++++
 examples/pom.xml                                   |  1 +
 8 files changed, 72 insertions(+), 16 deletions(-)
 copy examples/{camel-example-main-health => camel-example-routeloader}/pom.xml (86%)
 create mode 100644 examples/camel-example-routeloader/readme.adoc
 copy examples/{camel-example-csimple-joor => camel-example-routeloader}/src/main/java/org/apache/camel/example/MyApplication.java (82%)
 copy examples/{camel-example-kamelet => camel-example-routeloader}/src/main/resources/application.properties (86%)
 copy examples/{camel-example-routetemplate => camel-example-routeloader}/src/main/resources/logback.xml (100%)
 create mode 100644 examples/camel-example-routeloader/src/main/resources/myroutes/MyRouteBuilder.java


[camel-examples] 02/02: Regen

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-examples.git

commit 3494a3b59dacd8067554c2eba7c7d9c8fa2e403f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Feb 6 16:29:14 2021 +0100

    Regen
---
 examples/README.adoc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/examples/README.adoc b/examples/README.adoc
index bd5e49e..8feec0a 100644
--- a/examples/README.adoc
+++ b/examples/README.adoc
@@ -11,7 +11,7 @@ View the individual example READMEs for details.
 == Examples
 
 // examples: START
-Number of Examples: 86 (0 deprecated)
+Number of Examples: 89 (0 deprecated)
 
 [width="100%",cols="4,2,4",options="header"]
 |===
@@ -23,6 +23,8 @@ Number of Examples: 86 (0 deprecated)
 
 | link:camel-example-as2/README.adoc[AS2 Example] (camel-example-as2) | Beginner | An example which demonstrates the use of the Camel AS2 component
 
+| link:camel-example-azure-storage-blob/README.adoc[Azure Storage Blob] (camel-example-azure-storage-blob) | Beginner | Azure Storage Blob example
+
 | link:camel-example-basic/README.adoc[Basic] (camel-example-basic) | Beginner | Basic example
 
 | link:camel-example-cdi/README.adoc[CDI] (camel-example-cdi) | Beginner | An example showing how to work with Camel and CDI for dependency injection
@@ -41,6 +43,8 @@ Number of Examples: 86 (0 deprecated)
 
 | link:camel-example-java8/readme.adoc[Java8] (camel-example-java8) | Beginner | An example for showing Camel DSL for Java 8
 
+| link:camel-example-kamelet/readme.adoc[Kamelet] (camel-example-kamelet) | Beginner | How to use Kamelets
+
 | link:camel-example-main/readme.adoc[Main] (camel-example-main) | Beginner | An example for showing standalone Camel
 
 | link:camel-example-main-endpointdsl/readme.adoc[Main Endpointdsl] (camel-example-main-endpointdsl) | Beginner | An example for showing standalone Camel with Endpoint DSL
@@ -64,6 +68,8 @@ Number of Examples: 86 (0 deprecated)
 | link:camel-example-pojo-messaging/README.adoc[POJO Routing] (camel-example-pojo-messaging) | Beginner | An example showing how to produce and consume messages from Camel endpoints using annotated POJOs
     
 
+| link:camel-example-routeloader/readme.adoc[Routeloader] (camel-example-routeloader) | Beginner | Example loading and compiling Java routes on startup
+
 | link:camel-example-routetemplate/readme.adoc[Routetemplate] (camel-example-routetemplate) | Beginner | How to use route templates (parameterized routes)
 
 | link:camel-example-servlet-tomcat/README.adoc[Servlet Tomcat] (camel-example-servlet-tomcat) | Beginner | An example using Camel Servlet with Apache Tomcat
@@ -76,8 +82,6 @@ Number of Examples: 86 (0 deprecated)
 
 | link:camel-example-ssh/README.adoc[Ssh] (camel-example-ssh) | Beginner | An example that uses Camel SSH component
 
-| link:camel-example-azure-storage-blob/README.adoc[Azure Storage Blob List] (camel-example-azure-storage-blob) | Beginner | An example that uses Camel Azure Storage Blob and explain how list large blob container.
-
 | link:camel-example-cassandra-kubernetes/README.adoc[Cassandra Kubernetes] (camel-example-cassandra-kubernetes) | Cloud | An example with Camel and Cassandra running on Kubernetes
 
 | link:camel-example-cdi-aws-s3/README.adoc[CDI AWS S3] (camel-example-cdi-aws-s3) | Cloud | AWS S3 CDI example


[camel-examples] 01/02: add routes loader java example

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-examples.git

commit d1b8cfcee5c2ac057d02feb0dc2e6c70fb68635d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Feb 6 15:54:06 2021 +0100

    add routes loader java example
---
 examples/camel-example-routeloader/pom.xml         | 114 +++++++++++++++++++++
 examples/camel-example-routeloader/readme.adoc     |  29 ++++++
 .../org/apache/camel/example/MyApplication.java    |  39 +++++++
 .../src/main/resources/application.properties      |  24 +++++
 .../src/main/resources/logback.xml                 |  30 ++++++
 .../main/resources/myroutes/MyRouteBuilder.java    |  17 +++
 examples/pom.xml                                   |   1 +
 7 files changed, 254 insertions(+)

diff --git a/examples/camel-example-routeloader/pom.xml b/examples/camel-example-routeloader/pom.xml
new file mode 100644
index 0000000..9d612bd
--- /dev/null
+++ b/examples/camel-example-routeloader/pom.xml
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<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/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel.example</groupId>
+        <artifactId>examples</artifactId>
+        <version>3.8.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-example-routeloader</artifactId>
+    <packaging>jar</packaging>
+    <name>Camel :: Example :: Route Loader</name>
+    <description>Example loading and compiling Java routes on startup</description>
+
+    <properties>
+        <category>Beginner</category>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <!-- Add Camel BOM -->
+            <dependency>
+                <groupId>org.apache.camel</groupId>
+                <artifactId>camel-bom</artifactId>
+                <version>${camel.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-main</artifactId>
+        </dependency>
+        <!-- joor with java route loader -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-joor</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-timer</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-log</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-bean</artifactId>
+        </dependency>
+
+        <!-- logging -->
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>${log4j2-version}</version>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-core</artifactId>
+            <version>${logback-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>${logback-version}</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.camel</groupId>
+                <artifactId>camel-maven-plugin</artifactId>
+                <version>${camel.version}</version>
+                <configuration>
+                    <logClasspath>false</logClasspath>
+                    <mainClass>org.apache.camel.main.Main</mainClass>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/examples/camel-example-routeloader/readme.adoc b/examples/camel-example-routeloader/readme.adoc
new file mode 100644
index 0000000..c62aed1
--- /dev/null
+++ b/examples/camel-example-routeloader/readme.adoc
@@ -0,0 +1,29 @@
+== Camel Example Route Loader with Java
+
+This example shows how Camel is capable of loading routes during startup using the new route loader system.
+The route loader has support for loading routes in XML and Java (other languages to be added).
+
+This is the feature that was first developed as part of Camel K which has evolved to be a core
+part of Camel.
+
+The Java route loader is using `camel-joor` component which has the support for dynamic compiling Java source.
+
+The example has a Java route in the `src/main/resources/myroutes` directory. This route is a java file,
+but the file is not part of the regular source code and is therefore not compiled with the regular Java compiler.
+The route is loaded by Camels route loader and dynamic compiled via `camel-joor` during startup of Camel.
+
+=== How to run
+
+You can run this example using
+
+    mvn camel:run
+
+=== Help and contributions
+
+If you hit any problem using Camel or have some feedback, then please
+https://camel.apache.org/support.html[let us know].
+
+We also love contributors, so
+https://camel.apache.org/contributing.html[get involved] :-)
+
+The Camel riders!
diff --git a/examples/camel-example-routeloader/src/main/java/org/apache/camel/example/MyApplication.java b/examples/camel-example-routeloader/src/main/java/org/apache/camel/example/MyApplication.java
new file mode 100644
index 0000000..6de6397
--- /dev/null
+++ b/examples/camel-example-routeloader/src/main/java/org/apache/camel/example/MyApplication.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.example;
+
+import org.apache.camel.main.Main;
+
+/**
+ * Main class that boot the Camel application.
+ *
+ * This class has been added to make it easy to run the application from a Java editor.
+ * However you can start this application by running org.apache.camel.main.Main directory (see Maven pom.xml)
+ */
+public final class MyApplication {
+
+    private MyApplication() {
+    }
+
+    public static void main(String[] args) throws Exception {
+        // use Camels Main class
+        Main main = new Main();
+        // now keep the application running until the JVM is terminated (ctrl + c or sigterm)
+        main.run(args);
+    }
+
+}
diff --git a/examples/camel-example-routeloader/src/main/resources/application.properties b/examples/camel-example-routeloader/src/main/resources/application.properties
new file mode 100644
index 0000000..6e2e9cf
--- /dev/null
+++ b/examples/camel-example-routeloader/src/main/resources/application.properties
@@ -0,0 +1,24 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+# to configure camel main
+# here you can configure options on camel main (see MainConfigurationProperties class)
+camel.main.name = MyJavaLoader
+
+# which directory(s) to scan for routes which can be xml or java files
+camel.main.routes-include-pattern=classpath:myroutes/*.java
+
diff --git a/examples/camel-example-routeloader/src/main/resources/logback.xml b/examples/camel-example-routeloader/src/main/resources/logback.xml
new file mode 100644
index 0000000..a798d0b
--- /dev/null
+++ b/examples/camel-example-routeloader/src/main/resources/logback.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <root level="INFO">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
diff --git a/examples/camel-example-routeloader/src/main/resources/myroutes/MyRouteBuilder.java b/examples/camel-example-routeloader/src/main/resources/myroutes/MyRouteBuilder.java
new file mode 100644
index 0000000..b4d1666
--- /dev/null
+++ b/examples/camel-example-routeloader/src/main/resources/myroutes/MyRouteBuilder.java
@@ -0,0 +1,17 @@
+import java.util.Random;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyRouteBuilder extends RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        from("timer:foo?period=2s")
+            .setBody(method(MyRouteBuilder.class, "randomNumber"))
+            .log("Random number ${body}");
+    }
+
+    public static int randomNumber() {
+        return new Random().nextInt(100);
+    }
+}
diff --git a/examples/pom.xml b/examples/pom.xml
index c7558a5..48e0056 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -144,6 +144,7 @@
         <module>camel-example-pojo-messaging</module>
         <module>camel-example-reactive-executor-vertx</module>
         <module>camel-example-route-throttling</module>
+        <module>camel-example-routeloader</module>
         <module>camel-example-routetemplate</module>
         <module>camel-example-salesforce-consumer</module>
         <module>camel-example-servlet-tomcat</module>