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 aa59dc4  Move over jbang examples from camel-examples to here
aa59dc4 is described below

commit aa59dc4605249ad34b802ded652c80c643f2d27b
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Mar 14 11:15:02 2022 +0100

    Move over jbang examples from camel-examples to here
---
 jbang/hello-java/Hey.java             | 16 ++++++
 jbang/hello-java/README.adoc          | 96 +++++++++++++++++++++++++++++++++
 jbang/kafka-health/README.adoc        | 99 +++++++++++++++++++++++++++++++++++
 jbang/kafka-health/consumer.yaml      |  9 ++++
 jbang/kafka-health/docker-compose.yml | 27 ++++++++++
 jbang/kafka-health/producer.yaml      |  7 +++
 6 files changed, 254 insertions(+)

diff --git a/jbang/hello-java/Hey.java b/jbang/hello-java/Hey.java
new file mode 100755
index 0000000..d8ab5b8
--- /dev/null
+++ b/jbang/hello-java/Hey.java
@@ -0,0 +1,16 @@
+// use modeline to configure properties directly in the same source file
+// camel-k: language=java name=Cool property=period=1000
+
+public class Hey extends org.apache.camel.builder.RouteBuilder {
+
+  @Override
+  public void configure() throws Exception {
+      // Write your routes here, for example:
+      from("timer:java?period={{period}}")
+        .routeId("java")
+        .process(e -> {
+           e.getMessage().setBody("Hello from Camel");
+        })
+        .to("log:info");
+  }
+}
diff --git a/jbang/hello-java/README.adoc b/jbang/hello-java/README.adoc
new file mode 100644
index 0000000..fe3d0c5
--- /dev/null
+++ b/jbang/hello-java/README.adoc
@@ -0,0 +1,96 @@
+== Hello Java
+
+This example is a hello world example to run a Java route with Camel JBang.
+
+=== 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 Hey.java
+----
+
+Or run with JBang using the longer command line (without installing camel as 
app in JBang):
+
+[source,sh]
+----
+$ jbang camel@apache/camel run Hey.java
+----
+
+=== 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-examples/tree/main/examples/jbang
+----
+
+You can even try other examples such as the polyglot example from Camel K:
+
+[source,sh]
+----
+$ jbang camel@apache/camel run 
https://github.com/apache/camel-k/tree/main/examples/polyglot
+----
+
+Or the Kotlin route(s) (you can use wildcards):
+
+[source,sh]
+----
+$ jbang camel@apache/camel run 
https://github.com/apache/camel-k/tree/main/examples/languages/*.kts
+----
+
+=== Live reload
+
+You can run the example with reload enabled which allows you to edit the 
example,
+and hot-reload when the file is saved.
+
+[source,sh]
+----
+$ camel run Hey.java --reload
+----
+
+=== Developer Web Console
+
+You can enable the developer console via `--console` flag as show:
+
+[source,sh]
+----
+$ camel run Hey.java --console
+----
+
+Then you can browse: http://localhost:8080/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/kafka-health/README.adoc b/jbang/kafka-health/README.adoc
new file mode 100644
index 0000000..855b213
--- /dev/null
+++ b/jbang/kafka-health/README.adoc
@@ -0,0 +1,99 @@
+== Kafka and Health Checks
+
+This example shows how to run Camel connecting to a local Apache Kafka broker
+and have Camel health-checks report status as either UP or DOWN depending
+on stopping and starting the Kafka broker.
+
+=== Running Kafka broker
+
+You need Docker to run the local Kafka broker which can run via docker compose.
+
+[source,sh]
+----
+$ docker-compose up -d
+----
+
+And then you can stop and start the broker to make Camel health check report
+as either UP or DOWN.
+
+[source,sh]
+----
+$ docker-compose stop
+----
+
+and to start it again
+
+[source,sh]
+----
+$ docker-compose start
+----
+
+And to shutdown when you no longer need the broker.
+
+[source,sh]
+----
+$ docker-compose down
+----
+
+
+=== 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 consumer.yaml producer.yaml --health
+----
+
+Or run with JBang using the longer command line (without installing camel as 
app in JBang):
+
+[source,sh]
+----
+$ jbang camel@apache/camel run consumer.yaml producer.yaml --health
+----
+
+And you can also run the example by using wildcards, instead of typing every 
file name:
+
+[source,sh]
+----
+$ camel run * --health
+----
+
+Then you can access `http://localhost:8080/health` from a web browser to see 
the health status.
+
+Notice how you can check either the readiness or liveness health by invoking: 
`http://localhost:8080/health/live` and
+`http://localhost:8080/ready`. When the kafka brokers are not running then the 
liveness check should still be UP but
+readiness should be DOWN.
+
+
+=== 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/kafka-health/consumer.yaml b/jbang/kafka-health/consumer.yaml
new file mode 100644
index 0000000..83ad2e0
--- /dev/null
+++ b/jbang/kafka-health/consumer.yaml
@@ -0,0 +1,9 @@
+# camel-k: language=yaml
+
+- from:
+    uri: "kamelet:kafka-not-secured-source"
+    parameters:
+      topic: "foobar"
+      bootstrapServers: 'localhost:9092'
+    steps:
+    - to: "log:info?showAll=true&multiline=true"
\ No newline at end of file
diff --git a/jbang/kafka-health/docker-compose.yml 
b/jbang/kafka-health/docker-compose.yml
new file mode 100644
index 0000000..ed882bf
--- /dev/null
+++ b/jbang/kafka-health/docker-compose.yml
@@ -0,0 +1,27 @@
+---
+version: '3'
+services:
+  zookeeper:
+    image: confluentinc/cp-zookeeper:7.0.1
+    container_name: zookeeper
+    environment:
+      ZOOKEEPER_CLIENT_PORT: 2181
+      ZOOKEEPER_TICK_TIME: 2000
+
+  broker:
+    image: confluentinc/cp-kafka:7.0.1
+    container_name: broker
+    ports:
+      # To learn about configuring Kafka for access across networks see
+      # 
https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/
+      - "9092:9092"
+    depends_on:
+      - zookeeper
+    environment:
+      KAFKA_BROKER_ID: 1
+      KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
+      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 
PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
+      KAFKA_ADVERTISED_LISTENERS: 
PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://broker:29092
+      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
+      KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
+      KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
\ No newline at end of file
diff --git a/jbang/kafka-health/producer.yaml b/jbang/kafka-health/producer.yaml
new file mode 100644
index 0000000..fac1aeb
--- /dev/null
+++ b/jbang/kafka-health/producer.yaml
@@ -0,0 +1,7 @@
+# camel-k: language=yaml
+
+- from:
+    uri: "kamelet:chuck-norris-source"
+    steps:
+    - log: "${body}"
+    - to: 
"kamelet:kafka-not-secured-sink?topic=foobar&bootstrapServers=localhost:9092"

Reply via email to