简体   繁体   English

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

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

I have Spring integration pipeline which fetch document from SFTP server and persist it to Postgresql database (done by Spring data/hibernate). 我有Spring集成管道,该管道从SFTP服务器获取文档并将其持久保存到Postgresql数据库(由Spring数据/休眠完成)。 After successful sftp fetch pipeline get fileName and content (as byte[]) and persist it to database. sftp成功获取管道后,获取fileName和内容(作为byte [])并将其持久保存到数据库。

I have 2 main problems: 我有2个主要问题:

  1. Problem is that I haven't anticipated that client will upload 100Mb - 200MB zip files which pipeline reads but fails to persist. 问题是我没想到客户端会上传100Mb-200MB的zip文件,这些文件会被管道读取但无法持久保存。

  2. Sometimes (NOT ALAWAYS) "java.lang.OutOfMemoryError: Java heap space" is throwned, but increased Heap memory temporally resolved that, maybe there is solution that does not require to load whole file content to memory before persisting to database? 有时(不会)抛出 “ java.lang.OutOfMemoryError:Java堆空间”,但是增加的堆内存在时间上解决了这一问题,也许有一种解决方案不需要在持久存储到数据库之前将整个文件内容加载到内存中?

Only log message which is logged during transaction: 事务期间仅记录的日志消息:

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

I understand that I should share code, but really can't (legal issues). 我知道我应该共享代码,但实际上不能(法律问题)。

考虑在本地文件系统上使用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