0

I am able to copy the file from remote machine to local but not able to move the file to processed folder in remote server.

<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"  />

I am not able to move the file to processed folder in remote ftp

4

3 回答 3

1

If you need to rename a file on the remote machine, the upcoming 3.0 release now has a mv command on the (s)ftp outbound gateway.

于 2013-09-25T13:58:53.897 回答
1

I agree with Gary Russell that the best way would be to use mv command. But if you want to use current release, you can try configuration similar to this:

<?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 downloads the file from SFTP server to a local directory and outbound-channel-adapter places copy of that file in /processed folder on SFTP server.

Note that this is definitely not the best option, since you have to reupload your file to SFTP.

于 2013-09-25T14:37:25.900 回答
0

Please go through this link:

http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fac55462_.htm may be help to move file on remote server...

于 2013-09-25T13:28:11.953 回答