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 2024/01/30 10:26:53 UTC

(camel-kamelets-examples) branch main updated: Variable with EIP example

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 8925544  Variable with EIP example
8925544 is described below

commit 89255449c6d78f4cb51e14cfef5917631c935893
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jan 30 11:26:40 2024 +0100

    Variable with EIP example
---
 jbang/variables-eip/README.adoc | 52 +++++++++++++++++++++++++++++++++++++++++
 jbang/variables-eip/myapp.yaml  | 43 ++++++++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+)

diff --git a/jbang/variables-eip/README.adoc b/jbang/variables-eip/README.adoc
new file mode 100644
index 0000000..ea951b8
--- /dev/null
+++ b/jbang/variables-eip/README.adoc
@@ -0,0 +1,52 @@
+== Variables with EIPs
+
+This example shows how you can variables with EIPs with Camel routes.
+
+=== 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 myapp.yaml
+----
+
+Or run with wildcard:
+
+[source,sh]
+----
+$ camel run *
+----
+
+
+=== 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/variables-eip/myapp.yaml b/jbang/variables-eip/myapp.yaml
new file mode 100644
index 0000000..e05fe9f
--- /dev/null
+++ b/jbang/variables-eip/myapp.yaml
@@ -0,0 +1,43 @@
+# camel-k: language=yaml
+
+# Write your routes here, for example:
+- from:
+    uri: "timer:beers"
+    parameters:
+      period: "5000"
+    steps:
+      - to:
+          uri: "https://random-data-api.com/api/v2/beers"
+          variableReceive: beer1
+      - to:
+          uri: "https://random-data-api.com/api/v2/beers"
+          variableReceive: beer2
+      - setVariable:
+          name: alc1
+          expression:
+            jq:
+              expression: .alcohol | rtrimstr("%")
+              variableName: beer1
+              resultType: float
+      - setVariable:
+          name: alc2
+          expression:
+            jq:
+              expression: .alcohol | rtrimstr("%")
+              variableName: beer2
+              resultType: float
+#      - choice:
+#          when:
+#            - id: choice
+#              expression:
+#                simple:
+#                  expression: ${variable.alc1} > ${variable.alc2}
+#              steps:
+#                - log:
+#                    message: ${variable.beer1.name} (${variable.beer1.alcohol}) is stronger
+#          otherwise:
+#            steps:
+#              - log:
+#                  message: ${variable.beer2.name} (${variable.beer2.alcohol}) is stronger
+      - log: "Beer1: ${variable.beer1} with alc ${variable.alc1}"
+      - log: "Beer2: ${variable.beer2} with alc ${variable.alc2}"