I'm trying to remove out-of-date files in an sftp remote folder by using :
<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>
before getting into gateway there is a filter to select only the files out of date :
@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;
}
The questions are:
- why the header 'file_remoteFile' are not created automatically ?
- when the remote folder is empty and there is nothing to remove, the program can't stop. How should I solve this ?