spring-integration - 如何在将文件发送到 sftp 出站适配器之前检查文件计数
问题描述
我有一个 file:inbound-channel-adapter 扫描文件系统上的 6 个文件,然后将文件传递给 int-sftp:outbound-channel-adapter 以将文件发送到 sftp 服务器。我想检查是否所有 6 个文件在源目录中都可用,然后才将它们全部复制到 sftp 服务器。很高兴将根据文件名编写一些条件以取消发送到 sftp 服务器。
我能想到的唯一解决方案是使用聚合器来计算目录中的文件,然后使用拆分器将它们转换回单个消息,然后将它们引导到出站通道适配器。但是对于一个简单的案例来说,这种方法似乎很重要。
有没有简单的替代方案。基本上它是关于发送一组消息,如果该组符合标准。
这是我的配置:
<bean id="fileFilterBean" class="org.springframework.integration.file.filters.SimplePatternFileListFilter">
<constructor-arg value="*.DAT"></constructor-arg>
</bean>
<file:inbound-channel-adapter id="customerRelationChannelin" directory="file:${bwloan.outbound.sftp.ofsll.sharedFolder}" filter="fileFilterBean" >
<int:poller cron="${bwloan.outbound.sftp.file.cron.expr}" max-messages-per-poll="50">
</int:poller>
</file:inbound-channel-adapter>
<int:service-activator input-channel="customerRelationChannelin" output-channel="customerRelationChannelOut" ref="someHandler" />
<int-sftp:outbound-channel-adapter
id="custRelFtpOutboundAdapter" channel="customerRelationChannelOut"
remote-filename-generator-expression="payload.getName()"
remote-directory="${myapp.outbound.sftp.remoteDirectory}"
use-temporary-file-name="false"
order="1" session-factory="custRelSftpSessionFactory">
</int-sftp:outbound-channel-adapter>
解决方案
使用自定义 FileListFilter 过滤所有文件,直到出现 6 个文件。
推荐阅读
- mysql - ORDER BY FIELD 并结合 2 个值
- jsp - JSP:如何在输入标记中格式化 XMLGregorianCalendar
- python - 将代码的输出附加到它来自 python 数据框中的行
- flutter - 调整具有 iframe 的窗口大小时,Flutter UI 变得不稳定 - Flutter 最新版本:Flutter 2.3.0-24.1.pre
- django - ImageField 默认 upload_to 目录变化
- visual-studio - 如何使用 PIX 调试着色器
- c++ - WM_SETFOCUS 消息和 NULL wParam
- elasticsearch - 在 ElasticSearch 中为多词同义词添加排除项
- javascript - 如何从字符串创建单独的 android 键码
- azure - 如何更改 Azure 监控操作组管理员地址