I am reading root directory in FileReadingMessageSource from Spring Integration to retrieve ongoing file creations. Scenario is that there could be multiple sub-directories under root directory ongoing basis. WatchServiceDirectoryScanner from SI 4.3.1 is used to pick up any files created in any new sub-directory.
@Bean
public MessageSource<File> fileReadingMessageSource() {
CompositeFileListFilter<File> filters = new CompositeFileListFilter<>();
filters.addFilter(new SimplePatternFileListFilter("pattern*"));
//filters.addFilter(new LastModifiedFileListFilter());
FileReadingMessageSource fileSource = new FileReadingMessageSource();
String filePath = "root-directory";
fileSource.setDirectory(new File(filePath));
fileSource.setFilter(filters);
fileSource.setUseWatchService(true);
fileSource.setWatchEvents(FileReadingMessageSource.WatchEventType.CREATE,FileReadingMessageSource.WatchEventType.MODIFY,FileReadingMessageSource.WatchEventType.DELETE);
return fileSource;
}
@Bean
public IntegrationFlow readDirectoryFlow() {
return IntegrationFlows.from(
fileReadingMessageSource(),
e -> e.poller(Pollers.cron("*/5 * * * * *")))
.channel(fileInputChannel())
.handle(tailerRestart)
.handle(System.out::println)
.get();
}
On first poll, all files matching pattern are available via Message Resource but if any new files created later on in any new sub-directory then Message Resource is not able to pick new pattern matching files.
I see following DEBUG message in log
DEBUG SourcePollingChannelAdapter - Received no Message during the poll, returning 'false'
What could be missing ?