This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector-examples.git
The following commit(s) were added to refs/heads/master by this push: new eb1341d Added a Twitter Direct Message Sink connector example eb1341d is described below commit eb1341d47ba5ed6e209aff98bf9c89b1f2223427 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Wed Nov 25 07:25:14 2020 +0100 Added a Twitter Direct Message Sink connector example --- twitter/twitter-direct-message-sink/README.adoc | 74 ++++++++++++++++++++++ ...melTwitterdirectmessageSinkConnector.properties | 29 +++++++++ 2 files changed, 103 insertions(+) diff --git a/twitter/twitter-direct-message-sink/README.adoc b/twitter/twitter-direct-message-sink/README.adoc new file mode 100644 index 0000000..e0dbaed --- /dev/null +++ b/twitter/twitter-direct-message-sink/README.adoc @@ -0,0 +1,74 @@ +# Camel-Kafka-connector Twitter Direct Message Sink + +This is an example for Camel-Kafka-connector Twitter Direct Message Sink + +## Standalone + +### What is needed + +- A Twitter App with Read, write and direct message permissions + +### Setting up Twitter App and get credentials + +You'll need to create a twitter app and take note of access token, access token secret, consumer key and consumer secret. + +### Running Kafka + +``` +$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 +``` + +### Setting up the needed bits and running the example + +You'll need to setup 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 + +In this example we'll use `/home/oscerd/connectors/` + +``` +> cd /home/oscerd/connectors/ +> wget https://repo1.maven.org/maven2/org/apache/camel/kafkaconnector/camel-twitter-directmessage-kafka-connector/0.6.0/camel-twitter-directmessage-kafka-connector-0.6.0-package.zip +> unzip camel-twitter-directmessage-kafka-connector-0.6.0-package.zip +``` + +Now it's time to setup the connectors + +Open the Twitter sink configuration file + +``` +name=CamelTwitter-directmessageSinkConnector +connector.class=org.apache.camel.kafkaconnector.twitterdirectmessage.CamelTwitterdirectmessageSinkConnector +key.converter=org.apache.kafka.connect.storage.StringConverter +value.converter=org.apache.kafka.connect.storage.StringConverter + +topics=mytopic + +camel.sink.path.user=<user_id> +camel.sink.endpoint.accessToken=<access_token> +camel.sink.endpoint.accessTokenSecret=<access_token_secret> +camel.sink.endpoint.consumerKey=<consumer_key> +camel.sink.endpoint.consumerSecret=<consumer_secret> +``` + +Set the correct options in the file for the credentials part. + +Now you can run the example + +``` +$KAFKA_HOME/bin/connect-standalone.sh $KAFKA_HOME/config/connect-standalone.properties config/CamelTwitterdirectmessageSinkConnector.properties +``` + +In another terminal, using kafkacat, you can consume the messages + +``` +> echo "Hello from ckc" | ./kafkacat -b localhost:9092 -t mytopic +% Auto-selecting Producer mode (use -P or -C to override) +``` + +The user should now receive a direct message with "Hello from ckc" as body + diff --git a/twitter/twitter-direct-message-sink/config/CamelTwitterdirectmessageSinkConnector.properties b/twitter/twitter-direct-message-sink/config/CamelTwitterdirectmessageSinkConnector.properties new file mode 100644 index 0000000..5e41f98 --- /dev/null +++ b/twitter/twitter-direct-message-sink/config/CamelTwitterdirectmessageSinkConnector.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=CamelTwitter-directmessageSinkConnector +connector.class=org.apache.camel.kafkaconnector.twitterdirectmessage.CamelTwitterdirectmessageSinkConnector +key.converter=org.apache.kafka.connect.storage.StringConverter +value.converter=org.apache.kafka.connect.storage.StringConverter + +topics=mytopic + +camel.sink.path.user=<user_id> +camel.sink.endpoint.accessToken=<access_token> +camel.sink.endpoint.accessTokenSecret=<access_token_secret> +camel.sink.endpoint.consumerKey=<consumer_key> +camel.sink.endpoint.consumerSecret=<consumer_secret>