You can pick up the source code from:
- Checkout: http://jrecruiter.googlecode.com/svn/trunk/camellos/
- View: http://code.google.com/p/jrecruiter/source/browse/#svn/trunk/camellos
- Check out the source
- Using Maven run: mvn camel:run
- The Application should compile and start up correctly.
- You can now drop files into the camellos/inbox directory
- The files should get uploaded to its the FTP server running at localhost:3333
- The uploaded files should show up under camellos/ftp
- pick up files from an directory
- make sure that you pick up no more than 3 files per 30 seconds
- store them into a JMS queue
- have a listener on that queue that picks up those files
- and upload files to a remote FTP site
With Apache Camel you can get this simple task done with ZERO lines of Java code. Well, I needed 1 Main class with a few lines of code to load the Spring context and and the embedded FTP server. Nevertheless, I think that is quite impressive. In a sense all the heavy lifting is done in the Spring Application Context file:
<?xml version="1.0" encoding="UTF-8"?>
<amq:broker useJmx="false" persistent="false">
<amq:transportConnector uri="tcp://localhost:0" />
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="vm://localhost"/>
<ftpserver:server id="ftpServer" max-logins="10"
anon-enabled="true" max-anon-logins="5" max-login-failures="3"
<ftpserver:nio-listener name="default" port="3333" local-address="localhost"/>
<ftpserver:file-user-manager file="users.properties" encrypt-passwords="clear" />
<camel:camelContext shouldStartContext="true" trace="true">
<camel:from uri="file:camellos/inbox?move=.done" />
<camel:throttle maximumRequestsPerPeriod="1" timePeriodMillis="10000" >
<camel:from uri="activemq:queue:camellos" />
Apache Camel provides its own Maven plugin: http://camel.apache.org/camel-maven-plugin.html
Getting started with Apache Camel is simple. I recommend using m2Eclipse which is a Maven plugin for Eclipse. Basically Camel provides it's own Maven archetype which after running creates a simple project structure and which can be immediately run using mvn camel:run after project creation.
For my implementation I followed Camel's tutorial for creating a Spring based Camel route.
As my example uses a few more components for Apache Camel but also ActiveMQ for JMS and Apache Mina FTP Server, I needed some additional Maven dependencies.
Getting all the Maven dependencies right took actually longer than implementing the actual application logic. Anyway, I hope this gives you a quick overview of some basic Apache Camel features. As time permits I will blog about more about it soon. See you then!
PS: Apache Mina FtpServer, is itself a nice little nifty package. So if you for example have the need to boot-up dynamically FTP servers from within your application...check it out.