问题标签 [spring-integration-sftp]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1097 浏览

java - Spring integration SFTP - dont redowload locally deleted files

From reading the Spring SFTP docs (http://docs.spring.io/spring-integration/reference/html/sftp.html) it's not entirely clear if it's possible to prevent redownloading of successfully transferred files which subsequently get removed.

The files being transferred are large and get processed by a local task, and then can be deleted.

However, Spring SFTP is picking up that they have been removed (either at runtime or restart) and redownloading them.

I am already using the SftpPersistentAcceptOnceFileListFilter to survive restarts.

The above discussion refers to filtering the files before retrieving them. Once the files have been retrieved, an additional filter is applied to the files on the file system. By default, this is anAcceptOnceFileListFilter which, as discussed, retains state in memory and does not consider the file’s modified time. Unless your application removes files after processing, the adapter will re-process the files on disk by default after an application restart.

Also, if you configure the filter to use a FtpPersistentAcceptOnceFileListFilter, and the remote file timestamp changes (causing it to be re-fetched), the default local filter will not allow this new file to be processed.

Use the local-filter attribute to configure the behavior of the local file system filter. To solve these particular use cases, you can use a FileSystemPersistentAcceptOnceFileListFilter as a local filter instead. This filter also stores the accepted file names and modified timestamp in an instance of theMetadataStore strategy (Section 9.5, “Metadata Store”), and will detect the change in the local file modified time.

From this, where it mentions local files being removed, I don't know what I should be doing.

Here is my relevant config:

0 投票
1 回答
530 浏览

spring-integration - 重试 SFTP 权限错误

我正在维护一个现有的 Spring Integration 应用程序,该应用程序正在轮询第三方 SFTP 服务器以获取文件。它偶尔会抛出权限或“未找到”错误,我怀疑这是由远程端的暂时性问题引起的。我希望应用程序重试获取这些错误,因为它可能会解决问题。(我还要求“重试任何问题”,这应该涵盖这种情况。)

例如

经过广泛的谷歌搜索和转圈,我仍然无法弄清楚如何使用 Spring Integration 做到这一点。这是现有的配置:

编辑:我认为问题在于 myCompositeFilter。抛出异常时,看起来并没有在 myAcceptOnceFilter 内部调用 rollback() 。如果我只使用 myAcceptOnceFilter 而不使用复合,那么代码将按预期工作(即调用 rollback())。现在的问题是:我如何继续使用对所有子级调用回滚的 CompositeFilter?

我已经考虑在轮询器中放置一个重试适配器(编辑:我现在知道这无关紧要):

...但这会引发警告

简而言之,我被卡住了。任何有关让它重试这种 sftp 异常的帮助都将非常感激。谢谢!

编辑:添加提到 SftpPersistentAcceptOnceFileListFilter。编辑:添加了对 CompositeFileLIstFilter 的讨论,现在看起来像是问题的位置。

0 投票
1 回答
26786 浏览

java - Spring ClassPathResource - 无法打开,因为它不存在

更新:我仍然会将 Artem Bilan 的答案标记为正确,但我仍然觉得我需要为任何未来的读者指出这一点。看来我误解了@Value注释的“默认值”的概念。我希望通过使用来实现的功能

就是这样,如果 application.properties 中定义的文件路径 someProp 抛出异常(即找不到文件),它将尝试使用 defaultFilePath(即上面的那个)。定义默认值的实际作用是,如果属性本身 (someProp) 在 application.properties 文件中不存在(未定义或注释掉),则它会尝试使用默认值。


我正在使用 Spring Integration Sftp 进行 SSH 文件传输。使用 Spring Boot 所以没有 xml 文件。在配置DefaultSftpSessionFactory对象之前,我定义了一个包含 .txt 文件的资源,该文件具有 sFtp 身份验证所需的私钥。

以前,我FileSystemResource是这样使用的:

这工作得很好。但是,这个应用程序最终会被放到云环境中,这意味着像这样的绝对路径将不再起作用。我正在尝试改用 ClassPathResource 但无论我尝试什么都无法正常工作。到目前为止,我已经尝试了以下方法:

我的目录结构如下所示:

还有更多,但这是它的简化版本。谁能帮我弄清楚如何让它识别我的.txt的路径?java.io.FileNotFoundException: class path resource [resource] cannot be opened because it does not exist无论我尝试什么,我都会得到。

编辑:战争结构:

0 投票
1 回答
264 浏览

java - 从远程位置进行文件轮询,连接成功但使用 FTP Spring 集成从本地目录读取的问题

我在使用入站端时配置了带有 spring 集成的 FTP 我无法从远程路径获取文件,它总是从本地系统路径读取

ftp-inbound-listen-dynamic.xml

FtpInboundChannelResolver.java

FTPListnerService.java

这是我完整的 FTP 配置,但我无法从它从本地目录读取的 FTP 远程目录中读取

请帮忙

0 投票
1 回答
843 浏览

spring - 网络重置后 Spring 集成 FTP InboundChannelAdapter 死机

我们有一个使用downloadFTP 文件的用例,在网络重置后 ftp 入站适配器停止工作有一个奇怪的行为,这里是重现问题的步骤:

  1. 开始申请
  2. 应用程序开始将文件从 ftp 服务器下载到本地
  3. 定义的本地目录中出现了 filename.writing 文件
  4. 拔出网线(模拟网络重置情况)
  5. 应用程序停止下载文件(显然没有网络连接)
  6. 插入网络电缆。
  7. 下载未重新启动或重置,应用程序保持静止..
  8. 根本没有LOG发现这个问题。

提前致谢!

更新

这个问题应该通过添加超时来解决defSession.setConnectTimeout(Integer.valueOf(env.getProperty("ftp.timeout.connect")));

并且下面的代码是 FTP 读取客户端的工作示例

以下是代码片段:

0 投票
1 回答
1153 浏览

java - 如何使用spring从sftp服务器获取zip文件

我正在做一个项目,我在 sftp 服务器中有很多 zip 文件。我想要做的是连接到这个 sftp 服务器,并且对于每个 zip 文件(如果存在),将其传输到本地解压缩并制作我的进程。

我设法创建了我的解压缩类并为我的项目设置了弹簧配置。我开始寻找教程,并找到了示例集成 spring 示例,但我不明白两件事。如何获取已建立连接的信息以及如何知道此服务器中有一些 zip 文件?如果有人可以通过示例向我解释如何做到这一点,那就太好了。

0 投票
1 回答
2941 浏览

java - Spring Batch issue : "Problems occurred while synchronizing remote to local directory"

We PUT file on some SFTP server and then run spring batch.when spring batch run below steps were executed.

  1. pick file from FTP location

  2. process the file.

  3. delete file.

we are facing below exception while spring batch performing above steps.

0 投票
1 回答
1346 浏览

spring-integration - 使用 SourcePollingChannelAdapter 下载多个文件 - 启动/停止问题?

我的要求是从我的 spring-batch 应用程序的文件服务器中的远程目录下载多个文件。此处的示例之一 建议使用 SourcePollingChannelAdapter。在此示例中,适配器已启动 adapter.start() 但并未停止。那么它的生命周期是如何工作的呢?我的要求是首先下载&只有当所有文件都下载后,然后继续阅读文件。但这似乎是下载文件的一种异步过程。那么,当所有文件都已下载并准备好继续进行时,我将如何获得通知?我没有看到任何其他方法可以将任何处理程序注入适配器/可轮询通道。

使用的示例配置:

如果显式调用了adapter.stop(),它会抛出InterruptedException。如果未调用 stop ,则文件以异步方式下载而不会阻塞,因此下一步不知道下载是否已完成或正在进行中。

编辑:DownloadingTasklet 的代码片段

0 投票
2 回答
1496 浏览

spring-integration - Spring Integration-FTP 应该与本地文件夹同步

我有 ftp 位置文件和本地文件夹,在第一次将文件复制到本地并重新启动服务器时(当前它正在将已复制的文件复制到本地文件夹)它不应该查找已经存在的文件本地,它应该只查找新文件。请让我知道是否可以使用 Spring-Integration ftp 来实现它?我也添加了过滤器,但仍然无法正常工作,请告诉我哪里出错了,

0 投票
1 回答
133 浏览

spring-integration - FTP - 使用 Spring Integration 任务调度程序进程在一段时间后停止

当尝试在 Unix 机器上单独启动 jar 时,任务计划的线程在一段时间后没有监听,但它在 Windows 机器上工作正常。即使应用程序在启动时在 linux 中工作,但有时它不工作。请让我知道有什么办法可以避免这个问题。