java - Spring 集成 SFTP - 传输后处理

标签 java spring spring-integration sftp spring-integration-sftp

我已成功设置 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/

相关文章:

java - 是否有 jpa 或 hibernate 属性使所有查询不区分大小写

java - 如何在 Spring-Data-MongoDB 中使用 @Query 组合 AND 和 OR 子句?

spring for mongodb转义参数以避免SQL注入(inject)

java - 使用 Spring 和 Hibernate 从 SFTP 获取大文件并存储在 Postgresql 中的问题

java - Spring Integration 如何与 Web 服务( Jersey )交互?

java - 事务更改的子集有时在提交后不久不可见

java - 使用 cTakes AggregatePlaintextUMLSProcessor 的示例代码

java - 有关 Spring 转换器以及 Jaxb2RootElementHttpMessageConverter 如何在 Spring MVC 中工作的一些信息

java - 无效响应

Spring Data Rest - PATCH Postgres jsonb 字段