ฉันจะย้ายไฟล์จากระบบโลคัลไปยัง 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
หรือคุณสามารถอ่านไฟล์และวางเป็นเพย์โหลดด้วยตนเองในงาน corn และตัวเลือกอื่น ๆ อีกมากมาย คุณควรตัดสินใจว่าตัวเลือกใดที่เหมาะกับคุณที่สุด ในลิงก์ที่ฉันให้ไว้ด้านบนMessageChannel.send
ถูกเรียกอย่างชัดเจนและได้รับอินสแตนซ์ของช่องจากบริบทของแอป - นั่นก็เป็นตัวเลือกเช่นกัน - person Dmitry Kuskov   schedule 24.09.2013sftpSessionFactory
เป็นchannel
ในinbound-channel-adapter
ควรกำหนดช่องทางข้อความที่จะส่งต่อเพย์โหลดไป ดังนั้นในกรณีของคุณดูเหมือนว่าควรจะเป็นpublishToSFTPChannel
แล้วทำไมถึงใช้publish-subscribe-channel
? ช่องทางแบบจุดต่อจุดธรรมดาก็น่าจะเพียงพอแล้ว - person Dmitry Kuskov   schedule 24.09.2013