Reputation: 3184
I have a Spring integration application that does some processing on a file once it exists within a local directory. After it processes the file, it moves the file to a processed directory.
Some time later, a new file appears in that same local directory with the same file name but different content and time stamp. The application should once again process the file and then move it to a processed directory... but a message is never generated. Here's the config:
@Bean
@InboundChannelAdapter(value = "dailyFileInputChannel", poller = @Poller(maxMessagesPerPoll = "1", fixedDelay = "${load.manualPollingInterval}"))
public MessageSource<File> messageSource(ApplicationProperties applicationProperties) {
FileReadingMessageSource source = new FileReadingMessageSource();
source.setDirectory(applicationProperties.getLoadDirectory());
CompositeFileListFilter<File> compositeFileListFilter = new CompositeFileListFilter<File>();
compositeFileListFilter.addFilter(new LastModifiedFileListFilter());
FileSystemPersistentAcceptOnceFileListFilter persistent = new FileSystemPersistentAcceptOnceFileListFilter(store(), "dailyfilesystem");
persistent.setFlushOnUpdate(true);
compositeFileListFilter.addFilter(persistent);
compositeFileListFilter.addFilter(new SimplePatternFileListFilter(applicationProperties.getFileNamePattern()));
source.setFilter(compositeFileListFilter);
return source;
}
@Bean
public PropertiesPersistingMetadataStore store() {
PropertiesPersistingMetadataStore store = new PropertiesPersistingMetadataStore();
store.setBaseDirectory(applicationProperties.getProcessedStoreDirectory());
store.setFileName(applicationProperties.getProcessedStoreFile());
return store;
}
@Bean
@ServiceActivator(inputChannel = "dailyFileInputChannel")
public MessageHandler handler() {
// return a handler that processes and moves the file
}
I do not want the application process a file with the same name and same modified time stamp. How can I ensure the application though still processes files with the same name but different time stamps?
Upvotes: 3
Views: 1883
Reputation: 174664
Use a ChainFileListFilter
instead of a CompositeFileListFilter
.
The latter presents all files to each filter so, if the LastModifiedFileListFilter
filters a file on the first attempt (and the FileSystemPersistentAcceptOnceFileListFilter
passes it), the composite filter filters the file; on the next attempt it will be filtered again, even if it passes the first filter.
The ChainFileListFilter
won't pass a file filtered by the LastModifiedFileListFilter
to the next filter.
This was a recent "fix" (in 4.3.7 JIRA here).
The current version is 4.3.8.
Upvotes: 5