2
votes

Requirement: We are trying to implement an application and its functionality is to move a file from inbound folder to process folder over sftp with spring sftp outbound gateway. We have implemented sftp outbound gateway as shown below. When we executed application it is giving nothing, i.e., neither exception nor expected output (i.e., file is not moving over sftp)

<int-sftp:outbound-gateway id="remoteftpLS"
    session-factory="defaultSftpSessionFactory" request-channel="sftpRequestChannel"
    filename-regex=".*\.txt$" command="mv" expression="'/tmp/datlaa'"
    rename-expression="'/tmp/datlaa/archive'"  />

I want to move *.txt files from '/tmp/datlaa to /tmp/datlaa/archive.

Can you please suggest any configuration mistake from my side. or how to make it work?

Thanks

Adding application-context file http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/integration/sftp http://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd">

1

1 Answers

1
votes

The MV command deals with the single file:

The mv command has no options.

The expression attribute defines the "from" path and the rename-expression attribute defines the "to" path. By default, the rename-expression is headers['file_renameTo']. This expression must not evaluate to null, or an empty String. If necessary, any remote directories needed will be created. The payload of the result message is Boolean.TRUE. The original remote directory is provided in the file_remoteDirectory header, and the filename is provided in the file_remoteFile header. The new path is in the file_renameTo header.

See Spring Integration Reference Manual.

Your filename-regex is ignored there and both expression and rename-expression should point out to the target file.

If you would like to process a lot of files, like you are specifying with the filename-regex consider to use SFTP LS Gateway -> Spliter -> SFTP MV Gateway.