【发布时间】:2016-10-12 10:04:07
【问题描述】:
我正在尝试使用以下方法删除 sftp 远程文件夹中的过期文件:
<int-sftp:outbound-gateway
session-factory="sftpSessionFactory"
request-channel="rmChannel"
reply-channel="sftpOutputChannel"
remote-file-separator="/"
command="rm"
expression="headers['file_remoteDirectory'] + headers['file_remoteFile']">
<int-sftp:request-handler-advice-chain>
<si:retry-advice />
</int-sftp:request-handler-advice-chain>
</int-sftp:outbound-gateway>
在进入网关之前,有一个过滤器可以只选择过期的文件:
@Override
@Filter
public boolean accept(Message<?> message) {
if (message.getPayload() instanceof FileInfo) {
final FileInfo fileInfo = (FileInfo) message.getPayload();
final DateTime lastModified = new DateTime(fileInfo.getModified());
boolean accept = lastModified.plusDays(this.days).isBeforeNow();
return accept;
}
return false;
}
问题是:
- 为什么没有自动创建标头“file_remoteFile”?
- 当远程文件夹为空且没有可删除的内容时,程序无法停止。我应该如何解决这个问题?
【问题讨论】: