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/21 11:56:40 UTC

[camel-kafka-connector-examples] branch master updated: Added Telegram Sink Connector Example

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 43cb669  Added Telegram Sink Connector Example
43cb669 is described below

commit 43cb669b0b777f9d47d07ee9b5c8ecbfd50aa97f
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Oct 21 13:48:38 2020 +0200

    Added Telegram Sink Connector Example
---
 telegram/telegram-sink/README.adoc                 | 79 ++++++++++++++++++++++
 .../config/CamelTelegramSinkConnector.properties   | 27 ++++++++
 2 files changed, 106 insertions(+)

diff --git a/telegram/telegram-sink/README.adoc b/telegram/telegram-sink/README.adoc
new file mode 100644
index 0000000..c5d38c1
--- /dev/null
+++ b/telegram/telegram-sink/README.adoc
@@ -0,0 +1,79 @@
+# Camel-Kafka-connector Telegram Sink
+
+This is an example for Camel-Kafka-connector Telegram Sink 
+
+## Standalone
+
+### What is needed
+
+- A Telegram Bot
+- A ChatId
+
+### Setting up Telegram Bot and get Chat id
+
+First of all create a telegram bot on through the Bot Father channel in Telegram
+Take note of the BOT token.
+Create a group Chat with yourself and the BOT just created, or add the BOT to an existing group Chat.
+If you are lazy you can invite also the RawDataBot BOT and take note of the group chatId.
+In this example we created the ApacheCamelBot BOT.
+
+### Running Kafka
+
+```
+$KAFKA_HOME/bin/zookeeper-server-start.sh config/zookeeper.properties
+$KAFKA_HOME/bin/kafka-server-start.sh 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-telegram-kafka-connector/0.5.0/camel-telegram-kafka-connector-0.5.0-package.zip
+> unzip camel-telegram-kafka-connector-0.5.0-package.zip
+```
+
+Now it's time to setup the connectors
+
+Open the Telegram sink configuration file
+
+```
+name=CamelTelegramSinkConnector
+connector.class=org.apache.camel.kafkaconnector.telegram.CamelTelegramSinkConnector
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.sink.endpoint.authorizationToken=<bot_token>
+camel.sink.path.type=bots
+camel.sink.endpoint.chatId=<group_chat_id>
+```
+
+Set the correct options in the file.
+
+Now you can run the example
+
+```
+$KAFKA_HOME/bin/connect-standalone.sh $KAFKA_HOME/config/connect-standalone.properties config/CamelTelegramSinkConnector.properties
+```
+
+Check for messages in your chat
+
+In another terminal, using kafkacat, you should be able to send messages
+
+```
+> echo "Hello from Apache Camel" | ./kafkacat -b localhost:9092 -t mytopic 
+% Auto-selecting Producer mode (use -P or -C to override)
+```
+
+and in your group chat you should see messages coming from the ApacheCamelBot or the name of your BOT.
+
diff --git a/telegram/telegram-sink/config/CamelTelegramSinkConnector.properties b/telegram/telegram-sink/config/CamelTelegramSinkConnector.properties
new file mode 100644
index 0000000..4c26b81
--- /dev/null
+++ b/telegram/telegram-sink/config/CamelTelegramSinkConnector.properties
@@ -0,0 +1,27 @@
+#
+# 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=CamelTelegramSinkConnector
+connector.class=org.apache.camel.kafkaconnector.telegram.CamelTelegramSinkConnector
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.sink.endpoint.authorizationToken=<bot_token>
+camel.sink.path.type=bots
+camel.sink.endpoint.chatId=<group_chat_id>