java - Spring Integration SFTP: removing or noving multiple files -
with spring integration want move or remove multiple files or non-empty folders @ once on remote sftp server. can't seem find support in official spring docs, seems unsupported. although documentation isn't correct anyway.
i thinking using int-sftp:outbound-gateway
rm
command payload directory name. doesn't seem work. haven't tried mv
yet, i'm wondering if has experience behaviour in spring integration.
it's not clear question : files want remove local application or remote, on sftp server ?
below example of have in 1 app, maybe can : incoming messages (with file name in payload) first sent remote sftp server, , deleted locally
<integration:publish-subscribe-channel id="sftpchannel" /> <!-- processed file sftped server --> <sftp:outbound-channel-adapter id="sftpoutboundadapter" session-factory="sftpsessionfactory" channel="sftpchannel" order="1" charset="utf-8" remote-file-separator="/" remote-directory="${sftp.remote.directory}" remote-filename-generator-expression="payload.getname()" mode="replace" /> <!-- sftped file removed staging folder --> <integration:service-activator input-channel="sftpchannel" output-channel="nullchannel" ref="sftpfiledeleter" method="deleteaftersftpingfile" order="2" />
with sftpfiledeleter being
public class sftpfiledeleter {
private static final logger logger = logger .getlogger(sftpfiledeleter.class); @serviceactivator public void deleteaftersftpingfile(message<file> filemessage) throws ioexception{ path filetodeletepath = paths.get(filemessage.getpayload().getabsolutepath()); files.delete(filetodeletepath); logger.info("[sent]file sent sftp server , deleted:"+filetodeletepath.getfilename()); }
}
Comments
Post a Comment