【问题标题】:NFS inbound adapter configuration for multiple directory using single inbound adapter使用单个入站适配器的多个目录的 NFS 入站适配器配置
【发布时间】:2018-09-03 15:08:24
【问题描述】:

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

 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

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

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

   <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>

有人可以就此提出建议还是有其他方法也可以实现相同的目标

【问题讨论】:

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


    【解决方案1】:

    是的,您可以为此任务使用单个 &lt;file:inbound-channel-adapter&gt;。要使其旋转在目录列表上进行扫描,您需要为该适配器的&lt;poller&gt; 配置AbstractMessageSourceAdvice 实现,以便在afterReceive(boolean messageReceived, MessageSource&lt;?&gt; 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-16
      • 2018-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多