2015-10-21 36 views
0

我想構建一個簡單的實用程序,它將從多個目錄中的文件從一個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服務器(但不同的目錄),用於測試目的入站和出站文件。

回答

0

你需要更詳細地解釋你的問題 - 「沒有工作」是非常不足的,你在這個問題上得不到多少幫助。你需要展示你的嘗試和你觀察到的。

recursive mgetrecursive mput的測試案例。

測試的目錄結構顯示在該文件頂部的註釋中。

我建議你比較那些你試過的東西,如果你有一個具體的問題/觀察,就回到這裏。解決這些問題的最佳方法是打開DEBUG日誌記錄;包括jsch。