我有 Spring 集成管道,它從 SFTP 服務器獲取文檔并將其保存到 Postgresql 數據庫(由 Spring data/hibernate 完成)。成功后 sftp 獲取管道獲取文件名和內容(如 byte[])并將其保存到數據庫。我有兩個主要問題:問題是我沒有預料到客戶端會上傳 100Mb - 200MB 的 zip 文件,管道讀取但無法持久保存。有時(不總是)拋出“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."}我明白我應該分享代碼,但真的不能(法律問題)。
1 回答

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