2016-08-05 102 views
0

我使用int-sftp:入站通道适配器从远程目录下载文件。弹簧集成:int-sftp:入站通道适配器:如何检查源文件夹是否为空

我想检查远程目录是否为空,所以超时后,我停止下载和关闭应用程序。

那么如何检查远程目录是否为空以及如何使用超时?

我的源代码:

<int-sftp:inbound-channel-adapter id="sftpInbondAdapter" 
auto-startup="true" channel="receiveChannel" session-factory="sftpSessionFactory" 
local-directory="file:${directory.files.local}" remote-directory="${directory.files.remote}" 
auto-create-local-directory="true" delete-remote-files="true" 
filename-pattern="*.txt" > 
<int:poller 
max-messages-per-poll="-1" error-channel="sftp.in.error.channel"/> 

</int-sftp:inbound-channel-adapter> 

感谢

回答

0

目前在远程文件夹为空,没有任何迹象。

您可能会更容易使用出站网关。

您可以配置一个使用ls命令列出文件,另一个使用get(或mget)这些文件。

+0

我使用两个出站网关Shouls,每个命令一个? – NAZEHA

+0

我可以使用带有命令“ls”的出站网关来检查目录是否为空,然后使用sftp入站适配器下载文件? – NAZEHA

+0

每个网关处理单个命令[请参阅文档](http://docs.spring.io/spring-integration/reference/html/sftp.html#sftp-outbound-gateway)。是的,将'auto-startup'设置为false,并根据目录的内容,可以使用控制总线或直接获取对它的引用来启动适配器。 –

相关问题