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/13 10:15:15 UTC

[camel-kafka-connector-examples] branch master updated: Added a Sink Slack 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 c8e097f  Added a Sink Slack Connector example
c8e097f is described below

commit c8e097f4a330107e747920e7559f254c8d9e623e
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Oct 13 12:14:34 2020 +0200

    Added a Sink Slack Connector example
---
 slack/slack-sink/README.adoc                       | 80 ++++++++++++++++++++++
 .../config/CamelSlackSinkConnector.properties      | 26 +++++++
 2 files changed, 106 insertions(+)

diff --git a/slack/slack-sink/README.adoc b/slack/slack-sink/README.adoc
new file mode 100644
index 0000000..137ff76
--- /dev/null
+++ b/slack/slack-sink/README.adoc
@@ -0,0 +1,80 @@
+# Camel-Kafka-connector Slack Sink
+
+This is an example for Camel-Kafka-connector Slack Sink 
+
+## Standalone
+
+### What is needed
+
+- A Slack app
+- A Slack channel
+
+### Setting up Slack
+
+You'll need a workspace and a channel.
+
+In your Slack settings, create an app.
+
+Add the following permissions to your Bot Token scopes:
+* channels:history
+* channels:read
+
+Install the app on your workspace and select the channel you want to consume from. 
+
+Use the Bot User OAuth Access Token as token for this example.
+
+### 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-slack-kafka-connector/0.5.0/camel-slack-kafka-connector-0.5.0-package.zip
+> unzip camel-slack-kafka-connector-0.5.0-package.zip
+```
+
+Now it's time to setup the connectors
+
+Open the Slack sink configuration file
+
+```
+name=CamelSlackSinkConnector
+connector.class=org.apache.camel.kafkaconnector.slack.CamelSlackSinkConnector
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.sink.path.channel=general
+camel.component.slack.webhookUrl=<your_webhook_url>
+```
+
+Now you can run the example
+
+```
+$KAFKA_HOME/bin/connect-standalone.sh $KAFKA_HOME/config/connect-standalone.properties config/CamelSlackSinkConnector.properties
+```
+
+Check for messages in your channel
+
+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)
+```
+
diff --git a/slack/slack-sink/config/CamelSlackSinkConnector.properties b/slack/slack-sink/config/CamelSlackSinkConnector.properties
new file mode 100644
index 0000000..b41831f
--- /dev/null
+++ b/slack/slack-sink/config/CamelSlackSinkConnector.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=CamelSlackSinkConnector
+connector.class=org.apache.camel.kafkaconnector.slack.CamelSlackSinkConnector
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=test302
+
+camel.sink.path.channel=general
+camel.component.slack.webhookUrl=<your_webhook_url>