Spring SFTP 集成不轮询文件 [英] Spring SFTP Integration is not polling the file

查看:55
本文介绍了Spring SFTP 集成不轮询文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在我的应用程序中集成 Spring SFTP.这个想法是侦听 SFTP 路径,如果在 SFTP 中删除了任何文件,则读取该文件并更新数据库表.但我认为 Spring SFTP 入站是在系统之间传输文件.我找不到一个很好的例子来说明如何实现这一点.下面是我正在尝试的配置,但即使我放置了这个 xml 配置,也没有发生任何事情.我需要 XML 配置中的所有内容.有人可以给我一个关于如何实现该目标的示例,或者我如何修改我的配置以实现相同目标.

I have to integrate Spring SFTP in my application . The idea is to listen to a SFTP path and if any file is dropped in SFTP , read the file and update the DB tables . But i think Spring SFTP inbound is to transfer the files between systems . I could not find a good example on how to achieve that . below is the configuration i am trying , but nothing is happening even after i place this xml configuration . I need everything in XML configuration. Can someone suggest me a example on how to achieve that or how i can modify my configuration to achieve the same.

<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>

推荐答案

官方 repo 中有这个示例:https://github.com/spring-projects/spring-integration-samples/tree/master/basic/sftp

There is this sample in the official repo: https://github.com/spring-projects/spring-integration-samples/tree/master/basic/sftp

您确实应该确保将带有 .txt 扩展名的文件放在远程 /tmp/charge/ 中.

You really should be sure that you place there in the remote /tmp/charge/ the file with a .txt extension.

您可能还需要为 org.springframework.integration 开启 DEBUG 日志记录级别,以真正确定您的应用程序中发生了什么.

You probably also need to turn on DEBUG logging level for the org.springframework.integration to be really sure what is going on in your application.

这篇关于Spring SFTP 集成不轮询文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆