This component supports FTP via the Jakarta Commons Net library.

Sending files over FTP

The default behaviour of sending files over FTP is for the message content to be the text which gets written into the file. For example this example..

{snippet:id=content|lang=java|url=servicemix/smx3/trunk/common/servicemix-components/src/test/java/org/apache/servicemix/components/net/FTPTest.java}

will generate an XML text file on the FTP server. Here is an example of the FTP configuration on the server side.

{snippet:id=sender|lang=xml|url=servicemix/smx3/trunk/common/servicemix-components/src/test/resources/org/apache/servicemix/components/net/ftp.xml}

Using properties to specify the file name or content

You can use properties on the message to override the destination file name and content. e.g.

{snippet:id=properties|lang=java|url=servicemix/smx3/trunk/common/servicemix-components/src/test/java/org/apache/servicemix/components/net/FTPTest.java}

You can also use pluggable Expressions to configure the file name and/or file content.

If you do not specify a file name then a unique file name is created using a prefix you can specify (the uniqueFileName property).

{snippet:id=expression|lang=xml|url=servicemix/smx3/trunk/common/servicemix-components/src/test/resources/org/apache/servicemix/components/net/ftp.xml}

Polling for files

The FTPPoller will poll the server (with an optional path) for files on the FTP server then download them, fire them into the normalised message router and then delete them from the FTP server. Here's an example of this in action.

{snippet:id=poll|lang=xml|url=servicemix/smx3/trunk/common/servicemix-components/src/test/resources/org/apache/servicemix/components/net/ftpPoll.xml}
  • No labels