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..
Wiki Markup |
---|
{snippet:id=content|lang=java|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/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.
Wiki Markup |
---|
{snippet:id=sender|lang=xml|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/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.
Wiki Markup |
---|
{snippet:id=properties|lang=java|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/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).
Wiki Markup |
---|
{snippet:id=expression|lang=xml|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/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.
Wiki Markup |
---|
{snippet:id=poll|lang=xml|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/net/ftpPoll.xml} |