繁体   English   中英

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

[英]Problems in fetching large file from SFTP and storing in Postgresql using Spring and Hibernate

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

我有2个主要问题:

  1. 问题是我没想到客户端会上传100Mb-200MB的zip文件,这些文件会被管道读取但无法持久保存。

  2. 有时(不会)抛出 “ java.lang.OutOfMemoryError:Java堆空间”,但是增加的堆内存在时间上解决了这一问题,也许有一种解决方案不需要在持久存储到数据库之前将整个文件内容加载到内存中?

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

"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."}

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM