我有 Spring 集成管道,它從 SFTP 服務(wù)器獲取文檔并將其保存到 Postgresql 數(shù)據(jù)庫(由 Spring data/hibernate 完成)。成功后 sftp 獲取管道獲取文件名和內(nèi)容(如 byte[])并將其保存到數(shù)據(jù)庫。我有兩個主要問題:問題是我沒有預(yù)料到客戶端會上傳 100Mb - 200MB 的 zip 文件,管道讀取但無法持久保存。有時(不總是)拋出“java.lang.OutOfMemoryError:Java heap space”,但增加的堆內(nèi)存暫時解決了這個問題,也許有解決方案不需要在持久保存到數(shù)據(jù)庫之前將整個文件內(nèi)容加載到內(nèi)存?僅記錄事務(wù)期間記錄的消息:"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."}我明白我應(yīng)該分享代碼,但真的不能(法律問題)。
1 回答

PIPIONE
TA貢獻1829條經(jīng)驗 獲得超9個贊
考慮SftpStreamingMessageSource
在本地文件系統(tǒng)上使用不復制/粘貼:https ://docs.spring.io/spring-integration/docs/current/reference/html/#sftp-streaming
添加回答
舉報
0/150
提交
取消