| = 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 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-git-kafka-connector/0.11.0/camel-git-kafka-connector-0.11.0-package.tar.gz |
| > untar.gz camel-git-kafka-connector-0.11.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 |
| ... |
| ---- |
| |
| === 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 -f 'Headers: %h Value: %s' |
| % Auto-selecting Consumer mode (use -P or -C to override) |
| Headers: CamelHeader.CamelGitBranchLeaf=refs/tags/v1.0,CamelHeader.CamelGitBranchObjectId=bd25966a30119fd389493638a7ce75ccfbc4bc52,CamelProperty.CamelToEndpoint=direct://end?pollingConsumerBlockTimeout=0&pollingConsumerBlockWhenFull=true&pollingConsumerQueueSize=1000 Value: refs/tags/v1.0 |
| % Reached end of topic mytopic [0] at offset 1 |
| ---- |