我想構建一個簡單的實用程序,它將從多個目錄中的文件從一個sftp服務器複製到另一個服務器。具有多個子目錄的輪詢目錄
我試過使用sftp出站網關來用命令「mget」輪詢單個高級目錄,但它不起作用。所以我想寫兩個入站適配器(不是一個好的解決方案,但仍然希望這樣做很糟糕!)。
<int-sftp:inbound-channel-adapter
id="pdbInbound"
session-factory="sftpSessionFactory"
auto-create-local-directory="true" delete-remote-files="true"
filename-pattern="*.*" remote-directory="${remote.pdb.directory}"
local-directory="${local.pdb.directory}">
<int:poller fixed-rate="5000"/>
</int-sftp:inbound-channel-adapter>
<int-sftp:inbound-channel-adapter
id="galaxyInbound"
session-factory="sftpSessionFactory"
auto-create-local-directory="true" delete-remote-files="true"
filename-pattern="*.*" remote-directory="${remote.galaxy.directory}"
local-directory="${local.galaxy.directory}" >
<int:poller fixed-rate="5000"/>
</int-sftp:inbound-channel-adapter>
上面的代碼工作得很好,文件被複制到本地目錄,如預期。
當我需要將這些文件傳輸到具有與源目錄相同目錄結構的遠程目錄時,會出現問題。我無法使用帶有命令=「mput」和command-options =「-R」的sftp-outbound網關實現它。所以,我試圖寫下兩個出站適配器。但是隻有一個目錄被寫入遠程。 有什麼想法這裏出了什麼問題?
<int:service-activator input-channel="pdbInbound" output-channel="pdbOutbound" expression="payload"/>
<int:service-activator input-channel="galaxyInbound" output-channel="galaxyOutbound" expression="payload"/>
<int-sftp:outbound-channel-adapter id="sftPdbOutboundAdapter" auto-create-directory="true"
session-factory="sftpSessionFactory"
auto-startup="true"
channel="pdbOutbound"
charset="UTF-8"
remote-file-separator="/"
remote-directory="${remote.out.pdb.directory}"
mode="REPLACE">
</int-sftp:outbound-channel-adapter>
<int-sftp:outbound-channel-adapter id="sftpGalaxyOutboundAdapter" auto-create-directory="true"
auto-startup="true"
session-factory="sftpSessionFactory"
channel="galaxyOutbound"
charset="UTF-8"
remote-file-separator="/"
remote-directory="${remote.out.galaxy.directory}"
mode="REPLACE">
</int-sftp:outbound-channel-adapter>
<int:poller default="true" fixed-delay="50"/>
注:我使用相同的SFTP服務器(但不同的目錄),用於測試目的入站和出站文件。