Announcement Announcement Module
Collapse
No announcement yet.
FTPTarget Help Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • FTPTarget Help

    Hi, I'm very new in spring.
    I need to send a file to a ftp server with Spring Integration.

    I have sucess to retrieve files from FTP Server doing the following in my configuration file:

    ...
    <channel-adapter id="channelInput" source="fileFTP">
    <poller period="60000"/>
    </channel-adapter>
    <ftp-source id="fileFTP"
    host="localhost"
    port="21"
    username="cristian"
    password="123"
    local-working-directory="${java.io.tmpdir}/output"
    remote-working-directory="/"/>
    ....

    Like I said before, now I need to send file. How can I do that. Please, if you can send my and example.

    Thanks a lot and sorry my english. I speak spanish :-)

  • #2
    You're best off waiting a bit for Ftp support. Keep an eye out for the Spring Extenstions project dedicated to Spring Integration Adapters.

    Comment


    • #3
      An example

      public class CartrkFileDownloadClient {

      private final Logger logger = LoggerFactory.getLogger(
      CartrkFileDownloadClient.class);

      private QueuedFTPClientPool cartrkFtpClientPool;

      /**
      * Set method for cartrkFtpClientPool
      * @param cartrkFtpClientPool Ftp client pool
      */
      public void setCartrkFtpClientPool(QueuedFTPClientPool cartrkFtpClientPool) {
      this.cartrkFtpClientPool = cartrkFtpClientPool;
      }

      /**
      * Retrieves the specified file if it exists in the specified directory
      * @param fileName file which need to be downloaded
      * @return ByteArrayOutputStream Byte Array Output stream if file is found
      * else returns null
      */
      public ByteArrayOutputStream retrieveFile(String fileName) {

      logger.debug("Looking for a remote file", fileName);
      FTPClient ftpClient = null;
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      try {
      ftpClient = cartrkFtpClientPool.getClient();

      if (!ftpClient.retrieveFile(fileName, outputStream)) {

      return null;
      }

      } catch (Exception exception) {
      logger.error("Exception occurred while downloading CARTRK file", exception);
      }
      return outputStream;
      }
      }

      Comment


      • #4
        Thanks

        Thanks a lot pgangi, I will try to do with your example. :-)

        Comment


        • #5
          guys, you can go for the extensions project now http://www.springsource.org/extensions/se-sia.

          I would recommend using the FtpFileSource in combination with an inbound channel adapter. This synchronized the local working directory with the remote directory over ftp. The local directory is read by a FileReadingMessageSource, so you can use the built in transformers there.

          I did a substantial refactoring yesterday, so you might find some issues.

          Comment

          Working...
          X