0

我有 Spring 集成管道,它从 SFTP 服务器获取文档并将其保存到 Postgresql 数据库(由 Spring 数据/休眠完成)。成功后 sftp 获取管道获取文件名和内容(作为字节 [])并将其持久化到数据库。

我有两个主要问题:

  1. 问题是我没有预料到客户端会上传 100Mb - 200MB 的 zip 文件,管道读取但无法保存。

  2. 有时(不是 ALAWAYS) “java.lang.OutOfMemoryError: Java heap space”被抛出,但增加的堆内存暂时解决了这个问题,也许有解决方案不需要在持久化到数据库之前将整个文件内容加载到内存?

仅在事务期间记录的日志消息:

"thread":"task-scheduler-8","location":"org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.copyFileToLocalDirectory(AbstractInboundFileSynchronizer.java:430)","level":"WARN","message":"The remote file '-r-x------ 1 0        0           81062125 May 15 15:06 test.zip' has not been transferred to the existing local file './transfered-files/test.zip'. Consider removing the local file."}

我知道我应该共享代码,但实际上不能(法律问题)。

4

1 回答 1

1

考虑SftpStreamingMessageSource在本地文件系统上使用复制/粘贴的替代:https ://docs.spring.io/spring-integration/docs/current/reference/html/#sftp-streaming

于 2019-05-15T13:37:43.243 回答