java Spring SFTP集成未轮询该文件
我必须在我的应用程序中集成Spring SFTP。其思想是侦听SFTP路径,如果SFTP中有任何文件被丢弃,则读取该文件并更新DB表。但我认为Spring SFTP inbound是在系统之间传输文件。我找不到一个好的例子来说明如何做到这一点。 下面是我正在尝试的配置,但即使在放置此xml配置之后,也没有发生任何事情。我需要XML配置中的所有内容。 有人能给我举个例子说明如何实现这一点,或者我如何修改配置以实现同样的效果
<bean id="sftpSessionFactory"
class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="hostname"/>
<property name="port" value="22"/>
<property name="user" value="vkp"/>
<property name="password" value="1234"/>
</bean>
<int-sftp:inbound-channel-adapter id="sftpAdapterAutoCreate"
session-factory="sftpSessionFactory"
channel="requestChannel"
filename-pattern="*.txt"
remote-directory="/tmp/charge/"
local-directory="file:target/charge"
auto-create-local-directory="true"
local-filename-generator-expression="#this.toUpperCase() + '.a'"
delete-remote-files="false">
<int:poller fixed-rate="1000"/>
</int-sftp:inbound-channel-adapter>
# 1 楼答案
官方回购协议中有此样本:https://github.com/spring-projects/spring-integration-samples/tree/master/basic/sftp
您确实应该确保在远程
/tmp/charge/
中放置扩展名为.txt
的文件您可能还需要为
org.springframework.integration
打开DEBUG
日志记录级别,才能真正确定应用程序中发生了什么