【问题标题】:Spring-integration-file : inbound-channel-adapter with use-watch-service="true" and watch-events="CREATE,DELETE", are delete events well managed?Spring-integration-file : inbound-channel-adapter with use-watch-service="true" 和 watch-events="CREATE,DELETE",删除事件管理得好吗?
【发布时间】:2016-10-25 10:43:27
【问题描述】:

我正在使用 spring-integration-file(最新版本 4.3.4.RELEASE)来监视目录并获取有关 CREATE 和 DELETE 事件的消息。

这是我的 Spring 配置:

<int:channel id="canalFichiersFTP" />
<int-file:inbound-channel-adapter id="integrateurFichiersFTP" directory="#{gestionnaireChemins.cheminRepertoireEntrant}"
    use-watch-service="true" channel="canalFichiersFTP" auto-create-directory="false" watch-events="CREATE,DELETE">
    <int:poller id="pollerFichiersFTP" fixed-delay="${trt001.delai.verification.ftp}" />
</int-file:inbound-channel-adapter>
<int:service-activator input-channel="canalFichiersFTP" ref="trt001Scheduler" method="recevoirNouveauFichierFTP" />

我添加了 use-watch-service="true"(如 spring 文档 http://docs.spring.io/spring-integration/reference/html/files.html#watch-service-directory-scanner 中所述)以使用 FileReadingMessageSource.WatchServiceDirectoryScanner 和 watch-events="CREATE,DELETE" 在创建新文件时获取消息在目录中,并在删除并再次创建文件时收到消息。

但它不起作用,当我在目录中创建文件时,我收到一条消息,但是当我删除文件并再次创建它时,我没有收到消息,如果我很好理解我应该收到的文档一个。

此监视服务使用两个过滤器 AcceptOnceFileListFilter 和 IgnoreHiddenFileListFilter 收集在一个 CompositeFileListFilter 中。在 DELETE 事件中,WatchServiceDirectoryScanner 应该调用 CompositeFileListFilter 上的 remove 方法(这是一个 ResettableFileListFilter 并将调用 AcceptOnceFileListFilter 上的 remove 方法),但它没有。

我认为问题出在 FileReadingMessageSource.java 文件的第 501 行,我不明白为什么要在 FileReadingMessageSource.this.filter 而不是 this.filter 上进行 instanceof 比较,但也许我错过了什么? FileReadingMessageSource.this.filter 在运行时为空,然后没有对过滤器进行删除调用,我认为这就是 AcceptOnceFileListFilter 没有收到删除调用的原因,以及为什么当我删除文件并再次创建它时,我的代码会这样做' nt 收到消息(AcceptOnceFileListFilter 认为我已经收到它)。

请帮助我,这是 Spring 代码中的错误、我的配置中的错误还是我误解了 Spring 文档中的某些内容?

非常感谢您的帮助。

【问题讨论】:

    标签: spring spring-integration


    【解决方案1】:

    这是一个错误;通常这两个过滤器引用是相同的,但正如您所说,根据您的配置,源过滤器为空。

    我将打开一个 JIRA 问题;解决方法是显式设置ignore-hidden="true",解析器将正确添加过滤器。

    JIRA here.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-07-21
      • 1970-01-01
      • 1970-01-01
      • 2019-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多