You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2023/10/24 08:51:33 UTC

[camel-kamelets-examples] 01/01: Add also Kafka Kamelet Apicurio Sink Example to Kafka Apicurio folder

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

acosentino pushed a commit to branch improving-apicurio-example
in repository https://gitbox.apache.org/repos/asf/camel-kamelets-examples.git

commit a6822d7185d08cb331ac98de1eede91bc2ab1dd0
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Oct 24 10:50:28 2023 +0200

    Add also Kafka Kamelet Apicurio Sink Example to Kafka Apicurio folder
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 jbang/kafka-apicurio-schema-registry/README.md     | 13 +++++-
 .../application.properties                         |  2 +-
 .../kafka-apicurio-producer-kamelet.yaml           | 46 ++++++++++++++++++++++
 .../kafka-producer/pom.xml                         |  8 +++-
 4 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/jbang/kafka-apicurio-schema-registry/README.md b/jbang/kafka-apicurio-schema-registry/README.md
index e0af776..0922ae3 100644
--- a/jbang/kafka-apicurio-schema-registry/README.md
+++ b/jbang/kafka-apicurio-schema-registry/README.md
@@ -26,7 +26,7 @@ Run [`Produce.java`](./kafka-producer/src/main/java/com/acme/example/kafka/Produ
 mvn compile exec:java -Dexec.mainClass="com.acme.example.kafka.Produce"
 ```
 
-## Consume from Kafka without Kamelets
+## Produce to Kafka without Kamelets
 
 To consume messages using a Camel route, first install the kafka-producer maven project:
 ```bash
@@ -78,6 +78,17 @@ and after a message has been produced to Kafka you should see
 ]
 ```
 
+## Produce to Kafka with Kamelets
+
+You might also want to try out the specialized Kamelet sink for Apicurio Registry
+
+Follow the same approach but run
+
+then run:
+```bash
+jbang run camel@apache/camel run --local-kamelet-dir=<local_path_to_camel_kamelets> --kamelets-version=4.1.0-SNAPSHOT kafka-apicurio-producer-kamelet.yaml
+```
+
 ## Consume from Kafka with Kamelets
 
 You might also want to try out the specialized Kamelet for Apicurio Registry
diff --git a/jbang/kafka-apicurio-schema-registry/application.properties b/jbang/kafka-apicurio-schema-registry/application.properties
index 8202fae..bae24dc 100644
--- a/jbang/kafka-apicurio-schema-registry/application.properties
+++ b/jbang/kafka-apicurio-schema-registry/application.properties
@@ -1,3 +1,3 @@
 bootstrap.servers=localhost:9092
 topic=my-topic
-schema.registry.url=http://localhost:8080/apis/registry/v2
+schema.registry.url=http://0.0.0.0:8080/apis/registry/v2
diff --git a/jbang/kafka-apicurio-schema-registry/kafka-apicurio-producer-kamelet.yaml b/jbang/kafka-apicurio-schema-registry/kafka-apicurio-producer-kamelet.yaml
new file mode 100644
index 0000000..abe18ad
--- /dev/null
+++ b/jbang/kafka-apicurio-schema-registry/kafka-apicurio-producer-kamelet.yaml
@@ -0,0 +1,46 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+# camel-k: dependency=mvn:com.acme.example:kafka-apicurio-producer:0.1
+
+- beans:
+  - name: order
+    type: "#class:com.acme.example.kafka.models.Order"
+    properties:
+      orderId: 1
+      itemId: "123"
+      userId: "oscerd"
+      quantity: 3
+      description: "My item"
+
+- route:
+    from:
+      uri: "kamelet:timer-source"
+      parameters:
+        message: '{"id":"1","message":"Camel Rocks"}'
+        contentType: "application/json"
+        repeatCount: 1
+      steps:
+      - set-body:
+          simple: "${ref:order}"
+      - to: 
+          uri: "kamelet:kafka-apicurio-registry-not-secured-sink"
+          parameters:
+            topic: "{{topic}}"
+            bootstrapServers: "{{bootstrap.servers}}"
+            groupId: 'my-consumer-group'
+            apicurioRegistryUrl: '{{schema.registry.url}}'
diff --git a/jbang/kafka-apicurio-schema-registry/kafka-producer/pom.xml b/jbang/kafka-apicurio-schema-registry/kafka-producer/pom.xml
index fb16f3d..378c362 100644
--- a/jbang/kafka-apicurio-schema-registry/kafka-producer/pom.xml
+++ b/jbang/kafka-apicurio-schema-registry/kafka-producer/pom.xml
@@ -13,11 +13,17 @@
       <groupId>io.apicurio</groupId>
       <artifactId>apicurio-registry-serdes-avro-serde</artifactId>
       <version>2.4.12.Final</version>
+      <exclusions>
+        <exclusion>
+              <groupId>org.apache.kafka</groupId>
+              <artifactId>kafka-clients</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.kafka</groupId>
       <artifactId>kafka-clients</artifactId>
-      <version>3.4.0</version>
+      <version>3.5.1</version>
     </dependency>
     <dependency>
       <groupId>org.apache.avro</groupId>