I am currently writing my first Flink application and would like to monitor a folder for new files. Unfortunately I could not find many examples on this topic.
I found the readFile(fileInputFormat, path, watchType, interval, pathFilter, typeInfo)
function to monitor a directory.
public static void main(String[] args) throws Exception {
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DataStream<String> inputStream = env.readFile(new TextInputFormat(new Path(filePath)),filePath, FileProcessingMode.PROCESS_CONTINUOUSLY, 100);
inputStream.print();
env.execute("Flink streaming test");
}
I thought this function watches the folder and reads a file when it is added to the folder. However, only the first file that is added is read. I guess I didn't really understand the way it worked. Can someone explain to me why it doesn't work that way and what the right way would be?