O'Reilly logo

Just Spring Integration by Madhusudhan Konda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

FTP Adapters

Remote files are usually fetched by employing the File Transfer Protocol (FTP), while local files are transferred onto a remote server using the same FTP. These two tasks are supported by the framework using inbound and outbound channel adapters.

The inbound channel adapters connect to an FTP Server to fetch the remote files and pass them as messages with the current file (Message<File>) as payload. The outbound channel adapters act in the opposite direction: they connect to channels, consume the messages, and write them to remote server directories.

Both adapters, represented by inbound-channel-adapter and outbound-channel-adapter, are included in the ftp namespace support. Before setting up the adapters, one critical piece of information is required by the adapters: connection (or session) details.

Session Factory

The adapters should know the server details to connect to, including the username and password. Framework’s DefaultFtpSessionConnectionFactory class provides these details. You should declare this bean in your config file with the appropriate properties set. The bean reference is then provided to the adapters as a session-factory attribute.

First, let’s see how we can set up a session factory. In your XML file, declare the factory class and provide the necessary details:

<bean name="sessionFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory"> <property name="host" value="ftp.madhusudhan.com"/> <property name="username" value="jsi"/> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required