【问题标题】:aws s3 Spring Integration File Modification Monitoraws s3 Spring 集成文件修改监视器
【发布时间】:2018-09-06 04:49:39
【问题描述】:

我正在寻找 AWS s3 Spring 集成文件修改监视器示例。

要求:每当从 AWS S3 存储桶中修改文件时,必须将最新更改从 s3 传输到 EC2 实例。

我们有文件入站适配器的监视事件,但我正在寻找类似的适配器或用于 s3 操作的逻辑。

我们现在拥有的:

<int-file:inbound-channel-adapter id="modifiedFiles" directory="${input.directory}" use-watch-service="true" filter="acceptAllFilter" watch-events="MODIFY"/>

XML 配置:

<bean id="acceptOnceFilter"
    class="org.springframework.integration.file.filters.AcceptOnceFileListFilter" />

<integration:channel id="s3FilesChannel" />
<int-aws:s3-inbound-channel-adapter id="s3FilesChannelId" channel="s3FilesChannel"
             session-factory="s3SessionFactory"
             auto-create-local-directory="false"
             delete-remote-files="false"
             preserve-timestamp="true"
             local-directory="file:${localFilePath}"
             local-filter="acceptOnceFilter"
             remote-directory-expression="${bucket_name}"
             auto-startup="false"
             filename-regex="${regx_expresion}" 
             remote-file-separator="/" >
    <integration:poller fixed-delay="1000"/>
</int-aws:s3-inbound-channel-adapter>

<integration:channel id="s3FilesChannel">
    <integration:queue/>
</integration:channel>

【问题讨论】:

  • 请向我们提供您使用的代码,以便我们以更好的方式帮助您。
  • Himanshu,感谢您的回复。我还没有开始编码,只是分析这种类型的需求。
  • 为 s3 bucket 寻找类似的解决方案。 跨度>
  • 欢迎来到 Stack Overflow!其他用户将您的问题标记为低质量和需要改进。我重新措辞/格式化您的输入,使其更易于阅读/理解。请查看我的更改以确保它们反映您的意图。如果您对我有其他问题或反馈,请随时给我留言。
  • 请注意:切勿在 cmets 中添加更多信息。始终更新您的问题。

标签: spring-boot spring-integration spring-integration-aws


【解决方案1】:

AWS S3 没有这样的监视器。这是基于 HTTP 的远程协议,与基于 WatchService 的普通文件系统监视器不同。你不要拿苹果和苹果比较。

您需要使用标准的&lt;int-aws:s3-inbound-channel-adapter&gt;。默认情况下使用S3PersistentAcceptOnceFileListFilter,它会对远程文件的修改做出反应。好吧,基本上它会轮询远程文件并检查其lastmodified

Reference Manual查看更多信息:

另外,如果您将过滤器配置为使用FtpPersistentAcceptOnceFileListFilter,并且远程文件时间戳发生更改(导致它被重新获取)

同样的规则也适用于 AWS S3 通道适配器。

【讨论】:

  • 听起来我们已经准备好接受答案了:stackoverflow.com/help/someone-answers
  • 是的,正确的Artem。我正在尝试实施上述解决方案。我也猜想,我也应该使用 S3InboundFileSynchronizer 类来实现这一点。我说得对吗?
  • 没错。你还需要一个S3InboundFileSynchronizingMessageSource
  • 嗨 Artem,我在配置 org.springframework.beans.factory.BeanDefinitionStoreException 时收到以下错误:从类路径资源嵌套异常解析 XML 文档时出现意外异常是 java.lang.AbstractMethodError:org.springframework。 integration.file.config.AbstractRemoteFileInboundChannelAdapterParser.getPersistentAcceptOnceFileListFilterClass()Ljava/lang/Class;
  • 您没有使用兼容版本。 Spring Integration 版本的底线应该来自这个spring-integration-aws。依赖 Spring Boot 的版本并添加相应的 SI-AWS 依赖项也很棒
猜你喜欢
  • 1970-01-01
  • 2020-04-27
  • 2019-03-26
  • 2011-05-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-30
相关资源
最近更新 更多