what I would like to do is to track the files removed and apply certain logic around this (get the id and update the entities). I've found that we can pass a list of watch events inside the channel adapter including
FileReadingMessageSource.WatchEventType.DELETE
but when I remove the file from the folder I do not see any events triggered and the transformer is never being applied
@Bean
public IntegrationFlow integrationFlow(FileToMovieTransformer fileToMovieTransformer) {
return this.integrationFlowBuilder()
.transform(fileToMovieTransformer)
.channel(movieHandlerChannel())
.get();
}
private IntegrationFlowBuilder integrationFlowBuilder() {
return IntegrationFlows.from(
Files.inboundAdapter(new File(localFilmFolder))
.autoCreateDirectory(true)
.useWatchService(true)
.watchEvents(FileReadingMessageSource.WatchEventType.CREATE, FileReadingMessageSource.WatchEventType.DELETE)
.patternFilter("*.xml"),
e -> e.poller(Pollers.fixedDelay(10, TimeUnit.SECONDS)
));
}
I would say that you treat
DELETEwrong way:So, there is already nothing to emit as a message to downstream. We definitely talk here about a
FileReadingMessageSource. But withDELETEthere is nothing to read any more. Am I missing anything?And here is what we have in the Docs so far:
Therefore to achieve whatever you would like to do in case of
DELETEevent, you need to implementResettableFileListFilterand together withSimplePatternFileListFilteryou should composite them into theCompositeFileListFilter.When file is deleted , that
DELETEevent is emitted and we end up with the logic like:Where the mentioned
CompositeFileListFilterdefinitely implements thisResettableFileListFilterone and will delegate to your own implementation.