3

Following the Spring integration ftp doc , I have managed to send files to ftp server through the java config way:

@MessagingGateway
public interface MyGateway {

     @Gateway(requestChannel = "toFtpChannel")
     void sendToFtp(File file);

}

ss

    public static void main(String[] args) {
    ConfigurableApplicationContext context =
                new SpringApplicationBuilder(FtpJavaApplication.class)
                    .web(false)
                    .run(args);
    MyGateway gateway = context.getBean(MyGateway.class);
     // sending file to ftp server
    gateway.sendToFtp(new File("/foo/bar.txt"));
}

It seems to me that the code above is using the custom method 'sendToFtp()' to send file to target ftp server. My question is that how to add other methods to the MyGateway interface to implement the operations?

ls (list files)
get (retrieve file)
mget (retrieve file(s))
rm (remove file(s))
mv (move/rename file)
put (send file)
mput (send multiple files)
Luca Basso Ricci
  • 17,829
  • 2
  • 47
  • 69
rellocs wood
  • 1,381
  • 4
  • 21
  • 36

1 Answers1

0

Each FTP gateway can only handle one method.

You need to declare one for each, then...

@MessagingGateway
public interface MyGateway {

     @Gateway(requestChannel = "toFtpGetChannel")
     void sendToFtpGet(...);

     @Gateway(requestChannel = "toFtpPutChannel")
     void sendToFtpPut(...);

    ...

}
Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Is there a way to subscribe to any of the `requestChannel`. If yes, how? – Sibtain Oct 26 '17 at 07:56
  • It's not at all clear what you are asking; and, in any case, you must not ask new questions in comments to old answers. Ask a new question, with much more clarity of what you are trying to solve; reference this answer from the new question if it's pertinent. – Gary Russell Oct 26 '17 at 12:23