首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用单个入站适配器为多个目录配置NFS入站适配器

使用单个入站适配器为多个目录配置NFS入站适配器
EN

Stack Overflow用户
提问于 2018-09-03 15:08:24
回答 1查看 641关注 0票数 0

在春季集成中,我希望轮询来自不同源目录(配置的每个接口都有不同的源目录)的文件,这些文件在yml文件(动态)中配置为sourcePath,如下所示。用户可以添加N个接口。

代码语言:javascript
复制
 interfaces:
      -
        sourceType: NFS
        sourcePath: /Interface-1/Inbound/text
        target: Interface-1
        targetType: S3
        targetPath: test-bucket-1
      -
        sourceType: NFS
        sourcePath: /Interface-2/Inbound/text
        target: Interface-2
        targetType: S3
        targetPath: test-bucket-2

是否可以使用单个入站适配器(使用原子引用)轮询来自不同源文件夹的文件,或者需要多个入站适配器?

当前,应用程序从基本目录中轮询文件。

代码语言:javascript
复制
   <file:inbound-channel-adapter id="filesInboundChannel"
    directory="file:${base.path}" auto-startup="false" scanner="scanner" auto-create-directory="true">

    <integration:poller id="poller" max-messages-per-poll="${max.messages.per.poll}" fixed-rate="${message.read.frequency}" task-executor="pollingExecutor">
        <integration:transactional transaction-manager="transactionManager" />
    </integration:poller>       
  </file:inbound-channel-adapter>

有人能在这方面提出建议吗?或者有没有其他方法也能达到同样的目标?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-04 13:33:41

是的,您可以使用单个<file:inbound-channel-adapter>来完成此任务。要使其在用于扫描的目录列表上旋转,您需要为该适配器的AbstractMessageSourceAdvice配置一个<poller>实现,以便在afterReceive(boolean messageReceived, MessageSource<?> source)获得接收操作的false时更改目录。因此,这样下一次投票将得到一个新的目录进行扫描。

作为一个示例,您可以查看最近引入的RotatingServerAdvicehttps://github.com/spring-projects/spring-integration/blob/master/spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/RotatingServerAdvice.java

https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-channels-section.html#conditional-pollers

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52152299

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档