This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/main by this push:
new 54bc357dd migrate and improve kafka example
54bc357dd is described below
commit 54bc357dd1fa29c4e77c5bf3ba30b38e210b478a
Author: Kuthumi Pepple <[email protected]>
AuthorDate: Wed Jul 27 21:05:47 2022 +0100
migrate and improve kafka example
---
examples/README.md | 1 -
examples/kafka/README.md | 30 -------------
examples/kafka/SampleKafkaConsumer.java | 32 --------------
examples/kafka/application.properties | 24 -----------
examples/kafka/sasl_ssl/README.md | 51 -----------------------
examples/kafka/sasl_ssl/SaslSSLKafkaConsumer.java | 30 -------------
examples/kafka/sasl_ssl/SaslSSLKafkaProducer.java | 34 ---------------
examples/kafka/sasl_ssl/application.properties | 26 ------------
8 files changed, 228 deletions(-)
diff --git a/examples/README.md b/examples/README.md
index 170e8601b..f4fc1cba8 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -22,7 +22,6 @@ In this section you can find a few examples of certain
[`Camel` components](http
| Type | Description | Link |
|---|---|---|
-| Kafka | Component usage | [see examples](./kafka/)|
| Knative | Component usage | [see examples](./knative/)|
## Advanced usage examples
diff --git a/examples/kafka/README.md b/examples/kafka/README.md
deleted file mode 100644
index a65184968..000000000
--- a/examples/kafka/README.md
+++ /dev/null
@@ -1,30 +0,0 @@
-# Kafka Camel K examples
-
-This example shows how Camel K can be used to connect to a Kafka broker.
-
-## Authentication to Kafka
-
-We have a dedicated section to show [how to authenticate Camel K to
Kafka](./sasl_ssl/).
-
-## Simple usage
-
-To run this example first set-up Kafka on your k8s cluster.
-A convenient way to do so is by using the Strimzi project, if you are using
minikube follow these instructions at https://strimzi.io/quickstarts/minikube/
-
-For convenience create a configmap to contain the properties:
-```
-kubectl create configmap kafka.props
--from-file=examples/kafka/application.properties
-```
-
-IMPORTANT: The kafka.host value in application.properties needs to be set to
the CLUSTER-IP address of the my-cluster-kafka-bootstrap service in the kafka
namespace:
- `kubectl get services -n kafka | grep my-cluster-kafka-bootstrap | awk
'/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/ {print $3}'`
-
-Finally run this sample using the command:
-```
-./kamel run examples/kafka/SampleKafkaConsumer.java
--config=configmap:kafka.props
-```
-
-To create messages to be read use the producer command from the Strimzi page:
-```
-kubectl -n kafka run kafka-producer -ti
--image=strimzi/kafka:0.11.1-kafka-2.1.0 --rm=true --restart=Never --
bin/kafka-console-producer.sh --broker-list my-cluster-kafka-bootstrap:9092
--topic my-topic
-```
\ No newline at end of file
diff --git a/examples/kafka/SampleKafkaConsumer.java
b/examples/kafka/SampleKafkaConsumer.java
deleted file mode 100644
index 20e1eacfa..000000000
--- a/examples/kafka/SampleKafkaConsumer.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.
- */
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class SampleKafkaConsumer extends RouteBuilder {
- @Override
- public void configure() throws Exception {
- log.info("About to start route: Kafka Server -> Log ");
- from("kafka:{{consumer.topic}}?brokers={{kafka.host}}:{{kafka.port}}"
- + "&maxPollRecords={{consumer.maxPollRecords}}"
- + "&consumersCount={{consumer.consumersCount}}"
- + "&seekTo={{consumer.seekTo}}"
- + "&groupId={{consumer.group}}")
- .routeId("FromKafka")
- .log("${body}");
- }
-}
diff --git a/examples/kafka/application.properties
b/examples/kafka/application.properties
deleted file mode 100644
index 57239325b..000000000
--- a/examples/kafka/application.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-# 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.
-
-kafka.host=<see SampleKafkaConsumer.java for value to set here>
-kafka.port=9092
-consumer.topic=my-topic
-consumer.maxPollRecords=5000
-consumer.consumersCount=1
-consumer.seekTo=beginning
-consumer.group=kafkaGroup
diff --git a/examples/kafka/sasl_ssl/README.md
b/examples/kafka/sasl_ssl/README.md
deleted file mode 100644
index d6a5a2906..000000000
--- a/examples/kafka/sasl_ssl/README.md
+++ /dev/null
@@ -1,51 +0,0 @@
-# Kafka Camel K SASL SSL example
-
-This example shows how Camel K can be used to connect to a generic Kafka
broker using SASL SSL authentication mechanism. Edit the `application`
properties file with the proper values to be able to authenticate a Kafka
Broker and use any Topic.
-
-## Prerequisite
-
-You have a Kafka broker available on the cluster, or anywhere else accessible
from the cluster. You will need to edit the `application.properties` file
setting a "kafka broker", a "SASL username" and a "SASL password".
-
-## Secret Configuration
-
-For convenience create a secret to contain the sensitive properties in the
`application.properties` file:
-
-```
-kubectl create secret generic kafka-props --from-file application.properties
-```
-
-## Run a producer
-
-At this stage, run a producer integration to fill the topic with a message,
every 10 seconds:
-
-```
-kamel run --config secret:kafka-props SaslSSLKafkaProducer.java --dev
-```
-
-The producer will create a new message every 10 seconds, push into the topic
and log some information.
-
-```
-[2] 2021-05-06 08:48:11,854 INFO [FromTimer2Kafka] (Camel (camel-1) thread #1
- KafkaProducer[test]) Message correctly sent to the topic!
-[2] 2021-05-06 08:48:11,854 INFO [FromTimer2Kafka] (Camel (camel-1) thread #3
- KafkaProducer[test]) Message correctly sent to the topic!
-[2] 2021-05-06 08:48:11,973 INFO [FromTimer2Kafka] (Camel (camel-1) thread #5
- KafkaProducer[test]) Message correctly sent to the topic!
-[2] 2021-05-06 08:48:12,970 INFO [FromTimer2Kafka] (Camel (camel-1) thread #7
- KafkaProducer[test]) Message correctly sent to the topic!
-[2] 2021-05-06 08:48:13,970 INFO [FromTimer2Kafka] (Camel (camel-1) thread #9
- KafkaProducer[test]) Message correctly sent to the topic!
-```
-
-
-## Run a consumer
-
-Now, open another shell and run the consumer integration using the command:
-
-```
-kamel run --config secret:kafka-props SaslSSLKafkaConsumer.java --dev
-```
-
-A consumer will start logging the events found in the Topic:
-
-```
-[1] 2021-05-06 08:51:08,991 INFO [FromKafka2Log] (Camel (camel-1) thread #0 -
KafkaConsumer[test]) Message #8
-[1] 2021-05-06 08:51:10,065 INFO [FromKafka2Log] (Camel (camel-1) thread #0 -
KafkaConsumer[test]) Message #9
-[1] 2021-05-06 08:51:10,991 INFO [FromKafka2Log] (Camel (camel-1) thread #0 -
KafkaConsumer[test]) Message #10
-[1] 2021-05-06 08:51:11,991 INFO [FromKafka2Log] (Camel (camel-1) thread #0 -
KafkaConsumer[test]) Message #11
-```
\ No newline at end of file
diff --git a/examples/kafka/sasl_ssl/SaslSSLKafkaConsumer.java
b/examples/kafka/sasl_ssl/SaslSSLKafkaConsumer.java
deleted file mode 100644
index 42ed3f581..000000000
--- a/examples/kafka/sasl_ssl/SaslSSLKafkaConsumer.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-
-// kamel run --config secret:kafka-props SaslSSLKafkaConsumer.java --dev
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class SaslSSLKafkaConsumer extends RouteBuilder {
- @Override
- public void configure() throws Exception {
- log.info("About to start route: Kafka -> Log ");
- from("kafka:{{consumer.topic}}")
- .routeId("FromKafka2Log")
- .log("${body}");
- }
-}
diff --git a/examples/kafka/sasl_ssl/SaslSSLKafkaProducer.java
b/examples/kafka/sasl_ssl/SaslSSLKafkaProducer.java
deleted file mode 100644
index 85caeb58d..000000000
--- a/examples/kafka/sasl_ssl/SaslSSLKafkaProducer.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.
- */
-
-// kubectl create secret generic kafka-props --from-file application.properties
-// kamel run --config secret:kafka-props SaslSSLKafkaProducer.java --dev
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class SaslSSLKafkaProducer extends RouteBuilder {
- @Override
- public void configure() throws Exception {
- log.info("About to start route: Timer -> Kafka ");
- from("timer:foo")
- .routeId("FromTimer2Kafka")
- .setBody()
- .simple("Message #${exchangeProperty.CamelTimerCounter}")
- .to("kafka:{{producer.topic}}")
- .log("Message correctly sent to the topic!");
- }
-}
diff --git a/examples/kafka/sasl_ssl/application.properties
b/examples/kafka/sasl_ssl/application.properties
deleted file mode 100644
index 84b089bfe..000000000
--- a/examples/kafka/sasl_ssl/application.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-# 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.
-
-# Kafka config
-camel.component.kafka.brokers = ********.kafka.mycloud.com:443
-camel.component.kafka.security-protocol = SASL_SSL
-
-camel.component.kafka.sasl-mechanism = PLAIN
-camel.component.kafka.sasl-jaas-config=org.apache.kafka.common.security.plain.PlainLoginModule
required username=*** password=***;
-
-consumer.topic = test
-producer.topic = test
\ No newline at end of file