我能够将文件从远程计算机复制到本地,但无法将文件移动到远程服务器中的已处理文件夹。
<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中的已处理文件夹
我同意加里·罗素(Gary Russell)的观点,最好的方法是使用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服务器下载到本地目录,然后outbound-channel-adapter
将该文件的副本放在SFTP服务器上的/ processed文件夹中。
请注意,这绝对不是最佳选择,因为您必须将文件重新上传到SFTP。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句