javaspring-integrationspring-integration-dslspring-integration-sftpspring-integration-ftp

Spring Integration is not detecting files on FTP Folder


Currently I'm facing a problem where I don't know what to do to resolve it. I'm developing a simple application that transfer files through different FTP and SFTP servers to be processed. Well, at the beginnig those servers weren't ready, so I used Apache Mina and RebexTinySftpServer to set a FTP server and a SFTP server on my computer to test my development.

With those applications I completed and tested my application locally, so it was time to test it using the servers that will be used in production, but something is wrong with the FTP server and Spring Integration is not detecting the files that are put in the folder to be transferred to the SFTP server.

I have two folders on each server: one for Input files and the another one for Output files. So when Spring Integration detects that there's a new file in the Input folder on the SFTP Server, it transfers the file to the Input folder on FTP Server to be processed for another service. That part works fine.

After that service processes the file, it generates an output file and stores it in the Output folder on the FTP Server to be transferred to the Output folder on the SFTP server, but for some reason Spring Integration is not detecting those files and doesn't transfer none of them. This part is what I don't know how to solve because none Exception is being thrown, so I don't know what part of my code I have to modify.

Here is my code where I define the DefaultFtpSessionFactory:

public DefaultFtpSessionFactory ftpSessionFactory() {
    DefaultFtpSessionFactory session = new DefaultFtpSessionFactory();
    session.setUsername(username);
    session.setPassword(password);
    session.setPort(port);
    session.setHost(host);
    session.setFileType(FTP.ASCII_FILE_TYPE);
    session.setClientMode(FTPClient.PASSIVE_LOCAL_DATA_CONNECTION_MODE);
    return session;
}

And here is the code where I define the FTP Inbound Adapter:

@Bean
FtpInboundChannelAdapterSpec salidaAS400InboundAdapter() {
    return Ftp.inboundAdapter(as400Session.ftpSessionFactory())
            .preserveTimestamp(true)
            .remoteDirectory(as400Session.getPathSalida())
            .deleteRemoteFiles(true)
            .localDirectory(new File("tmp/as400/salida"))
            .temporaryFileSuffix(".tmp");
}

I should mention that the FTP Server is running on an AS/400 system, so maybe that has something to do with the situation I'm facing.


Solution

  • I found the solution of my problem. I'm posting this in case something similar happens to someone else.

    My project is using spring-integration-ftp 5.5.16 that has commons-net 3.8.0 as a dependency. For some reason, that version of commons-net wasn't retrieving the files inside the directory of the AS400, so I excluded that dependency from spring-integration-ftp and added commons-net 3.9.0 in my project. Now everything works fine.