2013-09-25 30 views
0

我能夠將文件從遠程機器複製到本地,但無法將文件移動到遠程服務器中的處理文件夾。春季集成sftp無法將文件移動到遠程文件夾中處理

<bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory"> 
<property name="host" value="test.com"/> 
<property name="user" value="test"/> 
<property name="password" value="test123"/> 
<property name="port" value="22"/> 
</bean> 

<int:publish-subscribe-channel id="publishToSFTPChannel" /> 

<sftp:inbound-channel-adapter local-directory="#{articlesLocalDirectory}" filename-pattern="*.xml" channel="publishToSFTPChannel" session-factory="sftpSessionFactory" remote-directory="#{articlesRemoteDirectory}"> 
<int:poller fixed-rate="12000"/> 
</sftp:inbound-channel-adapter> 


<file:outbound-channel-adapter id="moveProcessedFile" 
session-factory="sftpSessionFactory" 
channel="publishToSFTPChannel" 
directory="#{articlesRemoteDirectory}/processed" 
delete-source-files="true" /> 

我不能將文件移動到處理文件夾在遠程FTP

+0

你想達到什麼目的?您希望將文件從SFTP服務器下載到本地目錄,然後將相同的文件移動到同一臺SFTP服務器上的另一個目錄中?你的配置不適用於此。你有文件出站適配器,它只會將文件複製到本地目錄,而不是遠程,並且你不需要'session-factory'。請準確地描述你想要做什麼,因爲你在問題中說的和我在配置中看到的是不同的東西。 –

+0

@Dmitry再次感謝。我想要實現的是我想將文件從FTP複製到本地目錄。複製該文件後,我需要將FTP中的文件移動到同一遠程目錄中的已處理文件夾。 – sree

回答

1

我同意加里羅素,最好的辦法是使用mv命令。但是,如果你想使用當前版本中,你可以嘗試類似的配置如下:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:int="http://www.springframework.org/schema/integration" 
    xmlns:sftp="http://www.springframework.org/schema/integration/sftp" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/integration 
     http://www.springframework.org/schema/integration/spring-integration.xsd 
     http://www.springframework.org/schema/integration/sftp 
     http://www.springframework.org/schema/integration/sftp/spring-integration-sftp-2.2.xsd"> 

<bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory"> 
    <property name="host" value="localhost"/> 
    <property name="user" value="user01"/> 
    <property name="password" value="abc123"/> 
    <property name="port" value="990"/> 
</bean> 

<int:channel id="sftpChannel"/> 

<sftp:inbound-channel-adapter local-directory="/tmp/test" filename-pattern="*.xml" 
           channel="sftpChannel" session-factory="sftpSessionFactory" 
           remote-directory="/"> 
    <int:poller fixed-rate="5000"/> 
</sftp:inbound-channel-adapter> 

<sftp:outbound-channel-adapter channel="sftpChannel" session-factory="sftpSessionFactory" 
           remote-directory="/processed"/> 

</beans> 

inbound-channel-adapter從SFTP服務器上的文件下載到本地目錄和/處理的文件夾中的文件SFTP服務器上的outbound-channel-adapter地方複製。

請注意,這絕對不是最佳選擇,因爲您必須將文件重新上傳到SFTP。

1

如果您需要重命名遠程計算機上的文件,upcoming 3.0 release現在在(s)ftp出站網關上有一個mv命令。

相關問題