This is often the case when you are working on projects of the Project Integration type. users or other systems upload files to an FTP server, and then the system retrieves files from the FTP server for corresponding processing.
This article briefly introduces and provides an example of a requirement to use camel to monitor whether ftpserver has files and transfer the obtained files to another system for processing (the image is from camel in action)
1, build an FTP server, download filezilla installation from the http://sourceforge.net/projects/filezilla/files/, set up a user Yorker/123456.
You can refer to this URL http://xbeta.info/filezilla-server.htm
2. implement routing in camel:
CamelContext context = new DefaultCamelContext(); context.addRoutes(new RouteBuilder() { public void configure() { from("ftp://localhost/inbox?username=yorker&password=123456").to( "file:d:/temp/outbox"); } }); context.start(); boolean loop = true; while (loop) { Thread.sleep(25000); } context.stop();
Here is mainly for example camel's support for FTP, without the processing of processor. downstream system is just used as an example to put it in a local folder. however, when a project is actually implemented, it can be of another type in to, such as the queue of JMS, The Ftb inbound folder of other systems, and Web Service. if you write the URI from above to, it is uploaded to the FTP folder.
In addition to the jar package used by camel, you also need a http://commons.apache.org/net/download_net.cgi to download the commons-net.jar
See the http://blog.csdn.net/kkdelta/article/details/7231640 for how to add processor processing in the middle of the process