如何使用SFTP適配器將文件從本地系統移動到遠程FTP。我正在通過這些示例,並提及將文件從遠程FTP複製到本地計算機。用於sftp的彈簧集成
我需要將文件從本地計算機移動到遠程系統文件夾。
<?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:int-sftp="http://www.springframework.org/schema/integration/sftp"
xmlns:file="http://www.springframework.org/schema/integration/file"
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
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schema/integration/file/spring-integration-file-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"/>
<file:inbound-channel-adapter directory="#{T(System).getProperty('java.io.tmpdir')}" id="fileInbound"
channel="sftpChannel" filename-pattern="*.xml">
<int:poller fixed-rate="1000" max-messages-per-poll="100"/>
</file:inbound-channel-adapter>
<int-sftp:outbound-channel-adapter id="sftpOutboundAdapter" session-factory="sftpSessionFactory"
channel="sftpChannel" charset="UTF-8" remote-directory="/"
remote-file-separator="/"/>
</beans>
<file:outbound-channel-adapter id="moveProcessedFile"
channel="sftpChannel"
directory="file:#{configurationService.configuration.getProperty('acal.jde.publish.folder')}/processed"
delete-source-files="true" order="2" />
我試過這個,但無法將文件移動到已處理的文件夾。
你只需要'出境-channel-adapter'把文件放到SFTP。你用什麼來將你的有效載荷放到'inputChannel'上? –
順便說一句,你可以看到一個例子,通過SFTP [在這裏]將文件放在遠程目錄中(https://github.com/spring-projects/spring-integration-samples/blob/master/basic/sftp/src/test /java/org/springframework/integration/samples/sftp/SftpOutboundTransferSample.java) –
@Dmitry所以我只需要定義出站通道適配器?如果是的話如何配置本地文件夾需要選擇文件? – sree