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-kamelets-examples.git
The following commit(s) were added to refs/heads/main by this push: new 23ca156 Add custom kamelet example 23ca156 is described below commit 23ca15679847c0020135e3d937b5de3d64bbc0ff Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sun Dec 4 11:50:38 2022 +0100 Add custom kamelet example --- custom-kamelets/user-source.kamelet.yaml | 38 +++++++++++++++ jbang/user/README.adoc | 83 ++++++++++++++++++++++++++++++++ jbang/user/user.java | 12 +++++ 3 files changed, 133 insertions(+) diff --git a/custom-kamelets/user-source.kamelet.yaml b/custom-kamelets/user-source.kamelet.yaml new file mode 100644 index 0000000..bba3f57 --- /dev/null +++ b/custom-kamelets/user-source.kamelet.yaml @@ -0,0 +1,38 @@ +apiVersion: camel.apache.org/v1alpha1 +kind: Kamelet +metadata: + name: user-source + annotations: + camel.apache.org/kamelet.support.level: "Stable" + camel.apache.org/catalog.version: "main-SNAPSHOT" + camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgNjAgNjAiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDYwID [...] + camel.apache.org/provider: "Apache Software Foundation" + camel.apache.org/kamelet.group: "Users" + labels: + camel.apache.org/kamelet.type: "source" +spec: + definition: + title: "User Source" + description: "Produces periodic events about random users!" + type: object + properties: + period: + title: Period + description: The time interval between two events + type: integer + default: 5000 + types: + out: + mediaType: application/json + dependencies: + - "camel:timer" + - "camel:http" + - "camel:kamelet" + template: + from: + uri: "timer:user" + parameters: + period: "{{period}}" + steps: + - to: https://random-data-api.com/api/v2/users + - to: "kamelet:sink" diff --git a/jbang/user/README.adoc b/jbang/user/README.adoc new file mode 100644 index 0000000..16fa6bd --- /dev/null +++ b/jbang/user/README.adoc @@ -0,0 +1,83 @@ +== Custom Kamelet + +This example is using a custom Kamelet that fetches random user data. + + +=== Install JBang + +First install JBang according to https://www.jbang.dev + +When JBang is installed then you should be able to run from a shell: + +[source,sh] +---- +$ jbang --version +---- + +This will output the version of JBang. + +To run this example you can either install Camel on JBang via: + +[source,sh] +---- +$ jbang app install camel@apache/camel +---- + +Which allows to run CamelJBang with `camel` as shown below. + +=== How to run + +Then you can run this example using: + +[source,sh] +---- +$ camel run user.java +---- + +Or run with JBang using the longer command line (without installing camel as app in JBang): + +[source,sh] +---- +$ jbang camel@apache/camel run user.java +---- + +=== Live reload + +You can run the example in dev mode which allows you to edit the example, +and hot-reload when the file is saved. + +[source,sh] +---- +$ camel run user.java --dev +---- + +=== Run directly from github + +The example can also be run directly by referring to the github URL as shown: + +[source,sh] +---- +$ jbang camel@apache/camel run https://github.com/apache/camel-kamelets-examples/tree/main/jbang/user +---- + +=== Developer Web Console + +You can enable the developer console via `--console` flag as show: + +[source,sh] +---- +$ camel run user.java --console +---- + +Then you can browse: http://localhost:8080/q/dev to introspect the running Camel applicaton. + + +=== 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/jbang/user/user.java b/jbang/user/user.java new file mode 100644 index 0000000..bcc9f3d --- /dev/null +++ b/jbang/user/user.java @@ -0,0 +1,12 @@ +// camel-k: language=java + +import org.apache.camel.builder.RouteBuilder; + +public class user extends RouteBuilder { + + @Override + public void configure() throws Exception { + from("kamelet:user-source") + .log("${body}"); + } +}