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-examples.git


The following commit(s) were added to refs/heads/main by this push:
     new 1740791  Added chuck norris kamelet example
1740791 is described below

commit 1740791a8506fed65a0057086901c1521dae168a
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon May 31 08:48:11 2021 +0200

    Added chuck norris kamelet example
---
 examples/README.adoc                               |   4 +-
 examples/kamelet-chucknorris/README.adoc           |  48 +++++++++
 examples/kamelet-chucknorris/pom.xml               | 114 +++++++++++++++++++++
 .../src/main/resources/camel/my-route.xml          |   6 ++
 .../kamelets/chuck-norris-source.kamelet.yaml      |  40 ++++++++
 .../src/main/resources/logback.xml                 |  30 ++++++
 examples/pom.xml                                   |   1 +
 7 files changed, 242 insertions(+), 1 deletion(-)

diff --git a/examples/README.adoc b/examples/README.adoc
index 0b7bbc3..9a65d17 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: 92 (0 deprecated)
+Number of Examples: 93 (0 deprecated)
 
 [width="100%",cols="4,2,4",options="header"]
 |===
@@ -49,6 +49,8 @@ Number of Examples: 92 (0 deprecated)
 
 | link:kamelet/README.adoc[Kamelet] (kamelet) | Beginner | How to use Kamelets
 
+| link:kamelet-chucknorris/README.adoc[Kamelet Chucknorris] 
(kamelet-chucknorris) | Beginner | How easy it is to create your own Kamelets
+
 | link:kamelet-main/README.adoc[Kamelet Main] (kamelet-main) | Beginner | How 
to easily run Kamelets
 
 | link:main/README.adoc[Main] (main) | Beginner | An example for showing 
standalone Camel
diff --git a/examples/kamelet-chucknorris/README.adoc 
b/examples/kamelet-chucknorris/README.adoc
new file mode 100644
index 0000000..e2fa3ba
--- /dev/null
+++ b/examples/kamelet-chucknorris/README.adoc
@@ -0,0 +1,48 @@
+== Camel Example Kamelet Chuck Norris
+
+=== Introduction
+
+This example shows how you can build a simple Kamelet and use with your Camel 
applications.
+
+The kamelet is created as a YAML file in the `src/main/resources/kamelets' 
directory.
+We have developed a Chuck Norris Kamelet that periodically gets a joke from 
the Chuck Norris internet database.
+
+A Camel routes is _coded_ in the `my-route.xml` file using the XML DSL that 
uses the Kamelet,
+and log the result from the Kamelet to the console.
+
+=== Build
+
+You will need to compile this example first:
+
+[source,sh]
+----
+$ mvn compile
+----
+
+=== Run
+
+You can run this example using
+
+[source,sh]
+----
+$ mvn camel:run
+----
+
+The application is also built as a _fat jar_ (see `pom.xml`), which you can 
run with
+
+[source,sh]
+----
+$ mvn package
+$ java -jar target/camel-example-kamelet-yaml-3.11.0-jar-with-dependencies.jar
+----
+
+
+=== Help and contributions
+
+If you hit any problem using Camel or have some feedback, then please
+https://camel.apache.org/community/support/[let us know].
+
+We also love contributors, so
+https://camel.apache.org/community/contributing/[get involved] :-)
+
+The Camel riders!
diff --git a/examples/kamelet-chucknorris/pom.xml 
b/examples/kamelet-chucknorris/pom.xml
new file mode 100644
index 0000000..e2658b4
--- /dev/null
+++ b/examples/kamelet-chucknorris/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.11.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-example-kamelet-chucknorris</artifactId>
+    <packaging>jar</packaging>
+    <name>Camel :: Example :: Kamelet :: Chuck Norris</name>
+    <description>How easy it is to create your own Kamelets</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>
+
+        <!-- main to easily run with Kamelets -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-kamelet-main</artifactId>
+        </dependency>
+        <!-- to use XML DSL -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-xml-io-dsl</artifactId>
+        </dependency>
+
+        <!-- these dependencies are used by the kamelet -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-timer</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-http</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-jsonpath</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.KameletMain</mainClass>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/examples/kamelet-chucknorris/src/main/resources/camel/my-route.xml 
b/examples/kamelet-chucknorris/src/main/resources/camel/my-route.xml
new file mode 100644
index 0000000..3db4a36
--- /dev/null
+++ b/examples/kamelet-chucknorris/src/main/resources/camel/my-route.xml
@@ -0,0 +1,6 @@
+<routes xmlns="http://camel.apache.org/schema/spring";>
+    <route>
+        <from uri="kamelet:chuck-norris-source"/>
+        <log message="${body}"/>
+    </route>
+</routes>
\ No newline at end of file
diff --git 
a/examples/kamelet-chucknorris/src/main/resources/kamelets/chuck-norris-source.kamelet.yaml
 
b/examples/kamelet-chucknorris/src/main/resources/kamelets/chuck-norris-source.kamelet.yaml
new file mode 100644
index 0000000..4b41b93
--- /dev/null
+++ 
b/examples/kamelet-chucknorris/src/main/resources/kamelets/chuck-norris-source.kamelet.yaml
@@ -0,0 +1,40 @@
+apiVersion: camel.apache.org/v1alpha1
+kind: Kamelet
+metadata:
+  name: chuck-norris-source
+  annotations:
+    camel.apache.org/kamelet.support.level: "Preview"
+    camel.apache.org/catalog.version: "main-SNAPSHOT"
+    camel.apache.org/kamelet.icon: 
data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pg0KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJDYXBhXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDA
 [...]
+    camel.apache.org/provider: "Apache Software Foundation"
+    camel.apache.org/kamelet.group: "Chuck Norris"
+  labels:
+    camel.apache.org/kamelet.type: "source"
+spec:
+  definition:
+    title: "Chuck Norris Source"
+    description: |-
+      Gets peridically Chuck Norris jokes from http://www.icndb.com/
+    properties:
+      period:
+        title: Period
+        description: The interval (msec) to wait before getting the next joke
+        type: integer
+        default: 5000
+  types:
+    out:
+      mediaType: text/plain
+  dependencies:
+    - "camel:timer"
+    - "camel:http"
+    - "camel:jsonpath"
+  flow:
+    from:
+      uri: "timer:chuck"
+      parameters:
+        period: "{{period}}"
+      steps:
+        - to: "http://api.icndb.com/jokes/random";
+        - set-body:
+            jsonpath: "$.value.joke"
+        - to: "kamelet:sink"
\ No newline at end of file
diff --git a/examples/kamelet-chucknorris/src/main/resources/logback.xml 
b/examples/kamelet-chucknorris/src/main/resources/logback.xml
new file mode 100644
index 0000000..a798d0b
--- /dev/null
+++ b/examples/kamelet-chucknorris/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/pom.xml b/examples/pom.xml
index ac1ea76..1a6f805 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -123,6 +123,7 @@
         <module>jooq</module>
         <module>kafka</module>
         <module>kamelet</module>
+        <module>kamelet-chucknorris</module>
         <module>kamelet-main</module>
         <module>kotlin</module>
         <module>loan-broker-cxf</module>

Reply via email to