Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added sample for consuming a remote ftp server triggered by a route

...

See File Language for more samples.

Consuming a remote FTP server triggered by a route

The FTP consumer is build as a scheduled consumer to be used in the from route. However if you want to start consuming from a FTP server triggered within a route it's a bit cumbersome to do this in Camel 1.x (we plan to improve this in Camel 2.x). However it's possible as this code below demonstrates.

In the sample we have a Seda queue where a message arrives that holds a message containing a filename to poll from a remote FTP server. So we setup a basic FTP url as:

Wiki Markup
{snippet:id=e1|lang=java|url=activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromQueueThenConsumeFtpToMockTest.java}

And then we have the route where we use Processor within the route so we can use Java code. In this Java code we create the ftp consumer that downloads the file we want. And after the download we can get the content of the file and put it in the original exchange that continues being routed. As this is based on an unit test it routes to a Mock endpoint.

Wiki Markup
{snippet:id=e2|lang=java|url=activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromQueueThenConsumeFtpToMockTest.java}

Debug logging

This component has log level TRACE that can be helpful if you have problems.

...