[英]Problems in fetching large file from SFTP and storing in Postgresql using Spring and Hibernate
我有Spring集成管道,該管道從SFTP服務器獲取文檔並將其持久保存到Postgresql數據庫(由Spring數據/休眠完成)。 sftp成功獲取管道后,獲取fileName和內容(作為byte [])並將其持久保存到數據庫。
我有2個主要問題:
問題是我沒想到客戶端會上傳100Mb-200MB的zip文件,這些文件會被管道讀取但無法持久保存。
有時(不會)拋出 “ 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.