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 12:34:11 UTC

[camel-kafka-connector-examples] branch telegram-source created (now f43cdb7)

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

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


      at f43cdb7  Added a Telegram Source connector example

This branch includes the following new commits:

     new f43cdb7  Added a Telegram Source connector example

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[camel-kafka-connector-examples] 01/01: Added a Telegram Source connector example

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f43cdb722a4d60fee4ad8b60a472f220c105508c
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Oct 21 14:31:04 2020 +0200

    Added a Telegram Source connector example
---
 telegram/telegram-source/README.adoc               | 73 ++++++++++++++++++++++
 .../config/CamelTelegramSourceConnector.properties | 26 ++++++++
 2 files changed, 99 insertions(+)

diff --git a/telegram/telegram-source/README.adoc b/telegram/telegram-source/README.adoc
new file mode 100644
index 0000000..0e9808d
--- /dev/null
+++ b/telegram/telegram-source/README.adoc
@@ -0,0 +1,73 @@
+# Camel-Kafka-connector Telegram Source
+
+This is an example for Camel-Kafka-connector Telegram Source
+
+## Standalone
+
+### What is needed
+
+- A Telegram Bot
+
+### Setting up Telegram Bot and get Chat id
+
+First of all create a telegram bot through the Bot Father channel in Telegram and take note of the BOT token.
+
+### 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 source configuration file
+
+```
+name=CamelTelegramSourceConnector
+connector.class=org.apache.camel.kafkaconnector.telegram.CamelTelegramSourceConnector
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.source.endpoint.authorizationToken=<bot_token>
+camel.source.path.type=bots
+```
+
+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/CamelTelegramSourceConnector.properties
+```
+
+Send message to your BOT
+
+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)
+IncomingMessage{messageId=7, date=2020-10-21T12:13:10Z, from=User{id=217879046, is_bot='false', firstName='Andrea', lastName='Cosentino', username='Oscerd'}, text='Hello', chat=Chat{id='217879046', title='null', type='private', all_members_are_administrators='false'}, photo=null, video=null, audio=null, document=null, sticker=null, location=null, entities=null, caption=null, captionEntities=null, replyMarkup=null, game=null}
+% Reached end of topic mytopic [0] at offset 1
+```
+
diff --git a/telegram/telegram-source/config/CamelTelegramSourceConnector.properties b/telegram/telegram-source/config/CamelTelegramSourceConnector.properties
new file mode 100644
index 0000000..33ea25b
--- /dev/null
+++ b/telegram/telegram-source/config/CamelTelegramSourceConnector.properties
@@ -0,0 +1,26 @@
+#
+# 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=CamelTelegramSourceConnector
+connector.class=org.apache.camel.kafkaconnector.telegram.CamelTelegramSourceConnector
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.source.endpoint.authorizationToken=<bot_token>
+camel.source.path.type=bots