This is an example for Camel-Kafka-connector Twitter Timeline Sink
You’ll need to create a twitter app and take note of access token, access token secret, consumer key and consumer secret.
$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
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-timeline-kafka-connector/0.10.1/camel-twitter-timeline-kafka-connector-0.10.1-package.tar.gz
> untar.gz camel-twitter-timeline-kafka-connector-0.10.1-package.tar.gz
Now it’s time to setup the connectors
Open the Twitter sink configuration file
name=CamelTwitter-timelineSinkConnector
connector.class=org.apache.camel.kafkaconnector.twittertimeline.CamelTwittertimelineSinkConnector
tasks.max=1
key.converter=org.apache.kafka.connect.storage.StringConverter
value.converter=org.apache.kafka.connect.storage.StringConverter
topics=mytopic
camel.sink.path.timelineType=user
camel.sink.endpoint.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/CamelTwittertimelineSinkConnector.properties
In another terminal, using kafkacat, you can produce a message
> echo "Hello from ckc" | ./kafkacat -b localhost:9092 -t mytopic
% Auto-selecting Producer mode (use -P or -C to override)
The user should now post a tweet with "Hello from ckc" as body