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 2020/11/10 13:31:55 UTC

[camel-kafka-connector-examples] 01/01: Added Git Tag Source connector example

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

acosentino pushed a commit to branch git-tag-example
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector-examples.git

commit d91229d58b68766145d77f1b107928411feb6f5d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Nov 10 14:31:10 2020 +0100

    Added Git Tag Source connector example
---
 git/git-source-tag/README.adoc                     | 96 ++++++++++++++++++++++
 .../config/CamelGitSourceConnector.properties      | 26 ++++++
 2 files changed, 122 insertions(+)

diff --git a/git/git-source-tag/README.adoc b/git/git-source-tag/README.adoc
new file mode 100644
index 0000000..1091352
--- /dev/null
+++ b/git/git-source-tag/README.adoc
@@ -0,0 +1,96 @@
+= Camel-Kafka-connector Git Source Consuming Tags
+
+This is an example for Camel-Kafka-connector Git Source Consuming Tags
+
+== Standalone
+
+=== What is needed
+
+- A local git repository
+
+=== Running Kafka
+
+[source]
+----
+$KAFKA_HOME/bin/zookeeper-server-start.sh $KAFKA_HOME/config/zookeeper.properties
+$KAFKA_HOME/bin/kafka-server-start.sh $KAFKA_HOME/config/server.properties
+$KAFKA_HOME/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic mytopic
+----
+
+=== Download the connector package
+
+Download the connector package zip and extract the content to a directory. In this example we'll use `/home/oscerd/connectors/`
+
+[source]
+----
+> cd /home/oscerd/connectors/
+> wget https://repo1.maven.org/maven2/org/apache/camel/kafkaconnector/camel-git-kafka-connector/0.6.0/camel-git-kafka-connector-0.6.0-package.zip
+> unzip camel-git-kafka-connector-0.6.0-package.zip
+----
+
+=== Configuring Kafka Connect
+
+You'll need to set up the `plugin.path` property in your kafka
+
+Open the `$KAFKA_HOME/config/connect-standalone.properties` and set the `plugin.path` property to your choosen location:
+
+[source]
+----
+...
+plugin.path=/home/oscerd/connectors
+...
+----
+
+=== Setup the git repository
+
+We'll need a git repository at the beginning.
+
+[source]
+----
+> mkdir -p /tmp/test_repo/
+> cd /tmp/test_repo/
+> git init
+> touch test.txt
+> git add test.txt
+> git commit -a -m "first commit"
+> git tag -a v1.0 -m "my version 1.0"
+----
+
+Now we are ready to go
+
+=== Setup the connectors
+
+Open the Git configuration file at `$EXAMPLES/git/git-source-tag/config/CamelGitSourceConnector.properties`
+
+[source]
+----
+name=CamelGitSourceConnector
+connector.class=org.apache.camel.kafkaconnector.git.CamelGitSourceConnector
+tasks.max=1
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.source.path.localPath=/tmp/test_repo/
+camel.source.endpoint.type=tag
+----
+
+=== Running the example
+
+Run the kafka connect with the Git Source connector:
+
+[source]
+----
+$KAFKA_HOME/bin/connect-standalone.sh $KAFKA_HOME/config/connect-standalone.properties $EXAMPLES/git/git-source-branch/config/CamelGitSourceConnector.properties
+----
+
+On a different terminal run the kafkacat consumer
+
+[source]
+----
+./kafkacat -b localhost:9092 -t mytopic
+% Auto-selecting Consumer mode (use -P or -C to override)
+Ref[refs/tags/v1.0=c33eff7830d1d9624bd265e1998bbe7daa4c654d(-1)]
+% Reached end of topic mytopic [0] at offset 1
+----
diff --git a/git/git-source-tag/config/CamelGitSourceConnector.properties b/git/git-source-tag/config/CamelGitSourceConnector.properties
new file mode 100644
index 0000000..67f5927
--- /dev/null
+++ b/git/git-source-tag/config/CamelGitSourceConnector.properties
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+name=CamelGitSourceConnector
+connector.class=org.apache.camel.kafkaconnector.git.CamelGitSourceConnector
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.source.path.localPath=/home/oscerd/Desktop/test_repo
+camel.source.endpoint.type=tag