Apache Camel Hello World + JBoss Fuse | JavaInUse

JBoss Fuse Tutorial- Apache Camel Hello World


In previous project we created a Maven Project for deployment on JBoss Fuse. In this chapter we use the Camel File component to transfer file from one folder to the other and deploy it on JBoss Fuse.


This tutorial is explained in the below Youtube Video.

Lets Begin

The File component is present in the camel-core jar itself so no new dependency needs to be added. The camel configuration file is to be created in src->main->resources->META-INF->spring. This is the default path where
camel looks for the config files.
We will create Eclipse Maven project as follows-

The config file applicationContext.xml will be as follows.
We have created a camel context. Inside the 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"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
	xmlns:osgi="http://www.springframework.org/schema/osgi" xmlns:cxf="http://camel.apache.org/schema/cxf"
	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 -install mvn:com.javainuse/camel-file-transfer/0.0.1-SNAPSHOT.. This gives us a bundle-id. Next run the start bundle-id command.

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

See Also

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