File source
The File source connector pulls messages from files in directories and persists the messages to Pulsar topics.
The File source connector pulls messages from files in directories and persists the messages to Pulsar topics.
Configuration
The configuration of the File source connector has the following properties.
Property
Name | Type | Required | Default | Description |
---|---|---|---|---|
inputDirectory | String | true | No default value | The input directory to pull files. |
recurse | Boolean | false | true | Whether to pull files from subdirectory or not. |
keepFile | Boolean | false | false | If set to true, the file is not deleted after it is processed, which means the file can be picked up continually. |
fileFilter | String | false | [^\.].* | The file whose name matches the given regular expression is picked up. |
pathFilter | String | false | NULL | If recurse is set to true, the subdirectory whose path matches the given regular expression is scanned. |
minimumFileAge | Integer | false | 0 | The minimum age that a file can be processed. Any file younger than minimumFileAge (according to the last modification date) is ignored. |
maximumFileAge | Long | false | Long.MAX_VALUE | The maximum age that a file can be processed. Any file older than maximumFileAge (according to last modification date) is ignored. |
minimumSize | Integer | false | 1 | The minimum size (in bytes) that a file can be processed. |
maximumSize | Double | false | Double.MAX_VALUE | The maximum size (in bytes) that a file can be processed. |
ignoreHiddenFiles | Boolean | false | true | Whether the hidden files should be ignored or not. |
pollingInterval | Long | false | 10000L | Indicates how long to wait before performing a directory listing. |
numWorkers | Integer | false | 1 | The number of worker threads that process files. This allows you to process a larger number of files concurrently. However, setting this to a value greater than 1 makes the data from multiple files mixed in the target topic. |
Example
Before using the File source connector, you need to create a configuration file through one of the following methods.
-
JSON
-
YAML
Usage
Here is an example of using the File source connecter.
-
Pull a Pulsar image.
-
Start Pulsar standalone.
-
Create a configuration file file-connector.yaml.
-
Copy the configuration file file-connector.yaml to the container.
-
Download the File source connector.
-
Start the File source connector.
-
Start a consumer.
-
Write the message to the file test.txt.
The following information appears on the consumer terminal window.