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 2021/01/11 08:55:51 UTC
[camel-kafka-connector-examples] branch gh-pr created (now 9ebe1b4)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a change to branch gh-pr
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector-examples.git.
at 9ebe1b4 Added a Github source pullrequest connector example
This branch includes the following new commits:
new 9ebe1b4 Added a Github source pullrequest connector example
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[camel-kafka-connector-examples] 01/01: Added a Github source
pullrequest connector example
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch gh-pr
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector-examples.git
commit 9ebe1b4d66821be45e3e29df2af4e384132810ee
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Jan 11 08:55:44 2021 +0100
Added a Github source pullrequest connector example
---
github/github-source-pullrequest/README.adoc | 92 ++++++++++++++++++++++
.../config/CamelGithubSourceConnector.properties | 29 +++++++
2 files changed, 121 insertions(+)
diff --git a/github/github-source-pullrequest/README.adoc b/github/github-source-pullrequest/README.adoc
new file mode 100644
index 0000000..5b4ec82
--- /dev/null
+++ b/github/github-source-pullrequest/README.adoc
@@ -0,0 +1,92 @@
+= Camel-Kafka-connector Github Source Consuming Pull Request
+
+This is an example for Camel-Kafka-connector Github Source Consuming Pull Request
+
+== Standalone
+
+=== What is needed
+
+- A Github account
+- A Github Personal Access Token
+- A Github 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-github-kafka-connector/0.7.0/camel-github-kafka-connector-0.7.0-package.zip
+> unzip camel-github-kafka-connector-0.7.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
+...
+----
+
+Now we are ready to go
+
+=== Setup the connectors
+
+Open the Github configuration file at `$EXAMPLES/github/github-source-pullrequest/config/CamelGithubSourceConnector.properties`
+
+[source]
+----
+name=CamelGithubSourceConnector
+connector.class=org.apache.camel.kafkaconnector.github.CamelGithubSourceConnector
+tasks.max=1
+
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.source.endpoint.repoName=finnhub-java-client
+camel.source.endpoint.repoOwner=oscerd
+camel.source.path.type=pullrequest
+camel.source.endpoint.oauthToken=<personal_access_token>
+----
+
+Modify the oauthToken with your personal access token and a repository of your choice.
+
+In the example I'm pointing an oscerd's personal project https://github.com/oscerd/finnhub-java-client
+
+=== 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/github/github-source-pullrequest/config/CamelGithubSourceConnector.properties
+----
+
+Now create a Pull request on the selected repository.
+
+On a different terminal run the kafkacat consumer
+
+[source]
+----
+./kafkacat -b localhost:9092 -t mytopic -f 'Headers: %h Value: %s'
+% Auto-selecting Consumer mode (use -P or -C to override)
+Headers: CamelHeader.GitHubPullRequest=1,CamelHeader.GitHubPullRequestHeadCommitSHA=42d5a7f7dd2cdffd63ee5e7d79bb36a81008594a,CamelProperty.CamelToEndpoint=direct://end?pollingConsumerBlockTimeout=0&pollingConsumerBlockWhenFull=true&pollingConsumerQueueSize=1000 Value: Pull Request 1
+% Reached end of topic mytopic [0] at offset 1
+----
diff --git a/github/github-source-pullrequest/config/CamelGithubSourceConnector.properties b/github/github-source-pullrequest/config/CamelGithubSourceConnector.properties
new file mode 100644
index 0000000..38e9438
--- /dev/null
+++ b/github/github-source-pullrequest/config/CamelGithubSourceConnector.properties
@@ -0,0 +1,29 @@
+#
+# 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=CamelGithubSourceConnector
+connector.class=org.apache.camel.kafkaconnector.github.CamelGithubSourceConnector
+
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.source.endpoint.repoName=finnhub-java-client
+camel.source.endpoint.repoOwner=oscerd
+camel.source.path.type=pullrequest
+camel.source.endpoint.oauthToken=<personal_access_token>