The config file applicationContext.xml
will be as follows.
We have created a camel context
context we have written a camel route. This route uses the file component to tranfer file from one folder to other
Also here during the transfer from source folder we have written noop=true
, this tells the server that the
transferred file should remain in the source folder even after the transfer(copy paste). If this is not specified
then after the transfer the file gets deleted from the source folder(cut paste).
<?xml version="1.0" encoding="UTF-8"?>
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf-2.8.3.xsd">
<camelContext id="camelId" xmlns="http://camel.apache.org/schema/spring">
<camel:from uri="file:C:/inbox?noop=true" />
<camel:to uri="file:C:/outbox" />
That is the only code required.Now run the following Maven command-clean:install
Next go to fuse.bat and start it by double clicking on it.
To run the jar file that is generated in .m2 repo type the following command
This gives us a bundle-id. Next run the start bundle-id
Our camel-file-transfer application is now up and running.
If not already present a folder named inbox will get generated in C drive. Any file copied to this folder will get
automatically copied to a folder named outbox in C drive.
Download Source Code
Download it - Apache Camel Hello World
File Transfer using Java DSL Apache Camel
Integrate Apache Camel and ActiveMQ
EIP patterns using Apache Camel
Camel application deployment on JBoss Fuse
Apache Camel +Spring + ActiveMQ + JBoss Fuse
Apache Camel + Apache CXF SOAP Webservices
Apache Camel- Main Menu