Important
You are viewing documentation for an older version of Confluent Platform. For the latest, click here.
Kafka Connect FileStream Connectors¶
The Kafka Connect FileStream Connector examples are intended to show how a simple connector runs for those first getting started with Kafka Connect as either a user or developer. It is not recommended for production use. Instead, we encourage users to use them to learn in a local environment. The examples include both a file source and a file sink to demonstrate an end-to-end data flow implemented through Kafka Connect. The FileStream Connector examples are also detailed in the developer guide as a demonstration of how a custom connector can be implemented.
Quick Start¶
A simple demo of how to use the FileStreamSourceConnector and FileStreamSinkConnector is available in the Kafka Connect quick start guide.
FileSource Connector¶
The FileSource Connector reads data from a file and sends it to Apache Kafka®. Beyond the configurations common
to all connectors it takes only an input file
and output topic
as properties.
Here is an example configuration:
name=local-file-source
connector.class=FileStreamSource
tasks.max=1
file=/tmp/test.txt
topic=connect-test
This connector will read only one file and send the data within that file to Kafka. It will then watch the file for appended updates only. Any modification of file lines already sent to Kafka will not be reprocessed.
FileSink Connector¶
The FileSink Connector reads data from Kafka and outputs it to a local file. Multiple topics may be specified as with any other
sink connector. The FileSink Connector takes only a file
property in addition to the configurations common
to all connectors. Here is an example configuration:
name=local-file-sink
connector.class=FileStreamSink
tasks.max=1
file=/tmp/test.sink.txt
topics=connect-test
As messages are added to the topics specified in the configuration, they are produced to a local file as specified in the configuration.