blob: 107e7bd88832cf0acce590fccb5b6231ef52a291 [file] [log] [blame]
# Camel-Kafka-connector File Source
## Introduction
This is an example for Camel-Kafka-connector File source
## What is needed
- A File System
## Running Kafka
```
$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
```
## 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.11.5/camel-file-kafka-connector-0.11.5-package.tar.gz
> untar.gz camel-file-kafka-connector-0.11.5-package.tar.gz
```
Now it's time to setup the connectors
Open the File connector configuration file
```
name=CamelFileSourceConnector
connector.class=org.apache.camel.kafkaconnector.file.CamelFileSourceConnector
key.converter=org.apache.kafka.connect.storage.StringConverter
value.converter=org.apache.kafka.connect.storage.StringConverter
camel.source.maxPollDuration=10000
topics=mytopic
camel.source.path.directoryName=/tmp/kafkastuff/
camel.source.endpoint.idempotent=true
```
Now you can run the example
```
$KAFKA_HOME/bin/connect-standalone.sh $KAFKA_HOME/config/connect-standalone.properties config/CamelFileSourceConnector.properties
```
Create files into the /tmp/kafkastuff folder
On a different terminal run the kafka-consumer and you should see messages from the SQS queue arriving through Kafka Broker.
```
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic mytopic --from-beginning
GenericFile[/tmp/kafkastuff/temp.txt]
GenericFile[/tmp/kafkastuff/tttt.txt]
```