Как переместить файл из локальной системы на удаленный FTP с помощью адаптера SFTP. Я просматриваю примеры, и все они упоминают о копировании файлов с удаленного FTP на локальный компьютер.
Мне нужно переместить файлы с локального компьютера в удаленную системную папку.
<?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" />
Я пробовал это, но не смог переместить файл в обработанную папку.
outbound-channel-adapter
, чтобы поместить файл в SFTP. Что вы используете для размещения полезной нагрузки вinputChannel
? - person Dmitry Kuskov   schedule 24.09.2013outbound-channel-adapter
, вы указываете только входной канал. И то, как вы помещаете данные в этот канал, зависит от вас: вы можете, например, создать цепочку, которая будет читать локальный каталог и записывать полезную нагрузку вinputChannel
, или вы можете читать файл и вручную помещать его в качестве полезной нагрузки в кукурузное задание, и многие другие варианты, вы должны решить, какой из них вам больше подходит. В приведенной выше ссылкеMessageChannel.send
вызывается явно, а экземпляр канала получается из контекста приложения - это тоже вариант. - person Dmitry Kuskov   schedule 24.09.2013sftpSessionFactory
какchannel
вinbound-channel-adapter
? Он должен определять канал сообщений, на который должна быть перенаправлена полезная нагрузка, поэтому в вашем случае кажется, что это должно бытьpublishToSFTPChannel
. А зачем использоватьpublish-subscribe-channel
? Достаточно простого двухточечного канала. - person Dmitry Kuskov   schedule 24.09.2013