我想做的是跟踪删除的文件并应用某些逻辑(获取 id 并更新实体)。我发现我们可以在通道适配器中传递一个监视事件列表,包括
FileReadingMessageSource.WatchEventType.DELETE
但是当我从文件夹中删除文件时,我看不到任何触发的事件,并且从未应用过转换器
@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)
));
}