- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想知道是否有人知道我是否可以在 FileInboundChannelAdapter 中使用监视服务以及 LastModifiedFileListFilter?
下面的示例代码给出了相当不一致的结果。有时,文件只是位于文件夹中并且未被处理。
我怀疑监视服务可能与 LastModifiedFileListFilter 不兼容。例如
它找到新创建的文件。
新创建的最后修改时间为-1秒,所以它不处理它。
有没有人有这方面的经验?是否有推荐的方法来解决此问题并允许我在继续之前验证文件是否已完全写入?
@Bean
public IntegrationFlow ftpInputFileWatcher()
{
return IntegrationFlows.from(ftpInboundFolder(), filePoller())
.handle()
/*abbreviated*/
.get();
}
private FileInboundChannelAdapterSpec ftpInboundFolder() {
LastModifiedFileListFilter lastModifiedFileListFilter = new LastModifiedFileListFilter();
lastModifiedFileListFilter.setAge(5);
return Files.inboundAdapter(inboundFolder)
.preventDuplicates(false)
.useWatchService(true)
.filter(fileAgeFilterToPreventPrematurePickup());
}
protected Consumer<SourcePollingChannelAdapterSpec> filePoller(){
return poller -> poller.poller((Function<PollerFactory, PollerSpec>) p -> p.fixedRate(2000));
}
谢谢!
最佳答案
是的,这很好!
对,他们不兼容。 WatchService 是基于事件的,并将来自事件的文件存储到内部队列中。当轮询器触发其操作时,它会从该队列中轮询文件并应用其过滤器。由于 LastModifiedFileListFilter
丢弃该文件并且不再有任何事件,我们将不会再看到该文件。
请就此事提出一个 JIRA,我们会考虑如何成为。
同时,作为变通方法,不要将 WatchService 用于此类逻辑。
关于java - 带有监视服务和 LastModifiedFileListFilter 的 Spring Integration 文件轮询器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46417689/
我正在尝试从目录中读取一些文件,并且在文件检测和文件处理之间存在延迟。我在构建器模式中有这个: /** * The build function that will create a Composi
我想知道是否有人知道我是否可以在 FileInboundChannelAdapter 中使用监视服务以及 LastModifiedFileListFilter? 下面的示例代码给出了相当不一致的结果。
我是一名优秀的程序员,十分优秀!