This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch file-sink in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector-examples.git
commit 367a022ea74fb96316265a66283287261e14c73e Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Tue May 19 16:16:30 2020 +0200 Added a File sink connector example --- file/file-sink/README.md | 69 ++++++++++++++++++++++ .../config/CamelFileSinkConnector.properties | 27 +++++++++ 2 files changed, 96 insertions(+) diff --git a/file/file-sink/README.md b/file/file-sink/README.md new file mode 100644 index 0000000..79063ce --- /dev/null +++ b/file/file-sink/README.md @@ -0,0 +1,69 @@ +# Camel-Kafka-connector File Sink + +## Introduction + +This is an example for Camel-Kafka-connector File Sink + +## What is needed + +- A File System + +## 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 test +``` + +## 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-file-kafka-connector/0.1.0/camel-file-kafka-connector-0.1.0-package.zip +> unzip camel-file-kafka-connector-0.1.0-package.zip +``` + +Now it's time to setup the connectors + +Open the File Sink configuration file + +``` +name=CamelFileSinkConnector +topics=mytopic +tasks.max=1 +connector.class=org.apache.camel.kafkaconnector.file.CamelFileSinkConnector +key.converter=org.apache.kafka.connect.storage.StringConverter +value.converter=org.apache.kafka.connect.storage.StringConverter + +camel.sink.path.directoryName=/tmp/ +camel.sink.endpoint.fileName=kafkaconnect.txt +camel.sink.endpoint.fileExist=Append +``` + +and add the correct credentials for AWS. + +Now you can run the example + +``` +$KAFKA_HOME/bin/connect-standalone.sh $KAFKA_HOME/config/connect-standalone.properties config/CamelAWS2SNSSinkConnector.properties +``` + +On a different terminal run the kafka-producer and send messages to your Kafka Broker. + +``` +bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic mytopic +Test +Test 1 +``` + +You should see the messages appended to kafkaconnect.txt in /tmp/ folder. + diff --git a/file/file-sink/config/CamelFileSinkConnector.properties b/file/file-sink/config/CamelFileSinkConnector.properties new file mode 100644 index 0000000..9c2122c --- /dev/null +++ b/file/file-sink/config/CamelFileSinkConnector.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=CamelFileSinkConnector +topics=mytopic +tasks.max=1 +connector.class=org.apache.camel.kafkaconnector.file.CamelFileSinkConnector +key.converter=org.apache.kafka.connect.storage.StringConverter +value.converter=org.apache.kafka.connect.storage.StringConverter + +camel.sink.path.directoryName=/tmp/ +camel.sink.endpoint.fileName=kafkaconnect.txt +camel.sink.endpoint.fileExist=Append