我已成功设置 Spring 与 SFTP 集成,并正在轮询 SFTP 服务器并拉取文件。
我想知道的是,下载完成后是否可以在每个文件上触发一个任务?我不想走文件系统监视的道路 - Spring SFTP 中是否有内置的功能?
看了文档,貌似可以用Channels来实现。
这就是我的接收器 channel 当前的样子:
<int:channel id="receiveChannel">
<int:queue />
</int:channel>
我不确定需要做什么来触发客户拦截器或类似的。
编辑:Spring 文档中是这样说的:
It is also important to understand that SFTP Inbound Channel Adapter is a Polling Consumer and therefore you must configure a poller (either a global default or a local sub-element). Once the file has been transferred to a local directory, a Message with java.io.File as its payload type will be generated and sent to the channel identified by the channel attribute.
我不确定如何实现这一点 - 并且找不到任何示例。
最佳答案
看来你必须从 Enterprise Integration Patterns 开头开始并自己确定channel
是一体化中最重要的一等公民。
所以,你有一个 <int-sftp:inbound-channel-adapter>
,其职责是从远程目录轮询实体,将它们转到 java.io.File
(就像您在 RTFM 中注意到的那样)并作为 payload
发送的Message
到配置的 channel 。该 channel 的订阅者将接收该消息并在该 File
下执行一些所需的过程。 payload
.
另请参阅Spring Integration Samples了解更多信息。
关于java - Spring 集成 SFTP - 传输后处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37051856/