在春季集成中,我希望轮询来自不同源目录(配置的每个接口都有不同的源目录)的文件,这些文件在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>有人能在这方面提出建议吗?或者有没有其他方法也能达到同样的目标?
发布于 2018-09-04 13:33:41
是的,您可以使用单个<file:inbound-channel-adapter>来完成此任务。要使其在用于扫描的目录列表上旋转,您需要为该适配器的AbstractMessageSourceAdvice配置一个<poller>实现,以便在afterReceive(boolean messageReceived, MessageSource<?> source)获得接收操作的false时更改目录。因此,这样下一次投票将得到一个新的目录进行扫描。
作为一个示例,您可以查看最近引入的RotatingServerAdvice:https://github.com/spring-projects/spring-integration/blob/master/spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/RotatingServerAdvice.java
https://stackoverflow.com/questions/52152299
复制相似问题