我想递归地列出远程目录及其子目录中的文件。我知道可以通过调用 ListGateway 的 listFiles 方法来做到这一点:
列表列表 = listGateway.listFiles("/ussama/providers")
@MessagingGateway
public interface ListGateway {
@Gateway(requestChannel = "listSftpChannel")
List<File> listFiles(String dir);
}
@Bean
@ServiceActivator(inputChannel = "listSftpChannel")
public MessageHandler handler() {
SftpOutboundGateway sftpOutboundGateway = new SftpOutboundGateway(sftpSessionFactory(), "ls", "'/directory'");
return sftpOutboundGateway;
}
@Bean
public IntegrationFlow sftpOutboundListFlow() {
return IntegrationFlows.from("listSftpChannel")
.handle(new SftpOutboundGateway(sftpSessionFactory(), "ls", "payload")
).get();
}
但我想每隔 x 分钟做一次。有没有办法可以轮询远程目录以在每 x 分钟后列出文件。请给java配置。
紫衣仙女
相关分类