blob: 306451de0715c9d2bd1f1b5061e29b251615e0d4 [file] [log] [blame]
= 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 tar.gz 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.9.0/camel-github-kafka-connector-0.9.0-package.tar.gz
> untar.gz camel-github-kafka-connector-0.9.0-package.tar.gz
----
=== 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
----