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/10/23 16:08:46 UTC

[camel-kafka-connector-examples] 01/01: Added Twitter Search Source example

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

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

commit a5dfb9e9f1a2ab1140ef9aad120f2c9b08846046
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Oct 23 18:08:07 2020 +0200

    Added Twitter Search Source example
---
 twitter/twitter-search-source/README.adoc          | 75 ++++++++++++++++++++++
 .../CamelTwittersearchSourceConnector.properties   | 30 +++++++++
 2 files changed, 105 insertions(+)

diff --git a/twitter/twitter-search-source/README.adoc b/twitter/twitter-search-source/README.adoc
new file mode 100644
index 0000000..3f34896
--- /dev/null
+++ b/twitter/twitter-search-source/README.adoc
@@ -0,0 +1,75 @@
+# Camel-Kafka-connector Twitter Search Source
+
+This is an example for Camel-Kafka-connector Twitter Search Source
+
+## Standalone
+
+### What is needed
+
+- A Twitter App
+
+### 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-search-kafka-connector/0.5.0/camel-twitter-search-kafka-connector-0.5.0-package.zip
+> unzip camel-twitter-search-kafka-connector-0.5.0-package.zip
+```
+
+Now it's time to setup the connectors
+
+Open the Twitter source configuration file
+
+```
+name=CamelTwitter-searchSourceConnector
+connector.class=org.apache.camel.kafkaconnector.twittersearch.CamelTwittersearchSourceConnector
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.source.path.keywords=Apache Camel
+camel.source.endpoint.accessToken=<access_token>
+camel.source.endpoint.accessTokenSecret=<access_token_secret>
+camel.source.endpoint.consumerKey=<consumer_key>
+camel.source.endpoint.consumerSecret=<consumer_secret>
+camel.source.endpoint.count=1
+```
+
+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/CamelTwittersearchSourceConnector.properties
+```
+
+In another terminal, using kafkacat, you can consume the messages
+
+```
+> ./kafkacat -b localhost:9092 -t mytopic
+% Auto-selecting Consumer mode (use -P or -C to override)
+StatusJSONImpl{createdAt=Fri Oct 23 15:47:28 CEST 2020, id=1319636559298252801, text='How to Handle Errors with Spring and Apache Camel - https://t.co/Zwhnyw4SQc https://t.co/3GOZ11qZtX', source='<a href="https://ifttt.com" rel="nofollow">IFTTT</a>', isTruncated=false, inReplyToStatusId=-1, inReplyToUserId=-1, isFavorited=false, isRetweeted=false, favoriteCount=0, inReplyToScreenName='null', geoLocation=null, place=null, retweetCount=0, isPossiblySensitive=false, lang='en', contributorsI [...]
+% Reached end of topic mytopic [0] at offset 1
+```
+
diff --git a/twitter/twitter-search-source/config/CamelTwittersearchSourceConnector.properties b/twitter/twitter-search-source/config/CamelTwittersearchSourceConnector.properties
new file mode 100644
index 0000000..46e0c33
--- /dev/null
+++ b/twitter/twitter-search-source/config/CamelTwittersearchSourceConnector.properties
@@ -0,0 +1,30 @@
+#
+# 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-searchSourceConnector
+connector.class=org.apache.camel.kafkaconnector.twittersearch.CamelTwittersearchSourceConnector
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.source.path.keywords=Apache Camel
+camel.source.endpoint.accessToken=<access_token>
+camel.source.endpoint.accessTokenSecret=<access_token_secret>
+camel.source.endpoint.consumerKey=<consumer_key>
+camel.source.endpoint.consumerSecret=<consumer_secret>
+camel.source.endpoint.count=1