My new website on Artificial Intelligence and Machine Learning

Apache Camel integration with Spring

Apache Camel can be integrated with Spring using xml configuration file

Here I will provide a tutorial on how you can get started with Apache Camel in xml.If we follow xml based configuration, there is no use of Router class.

Below xml is Camel xml configuration using spring itegration, using this I am trying to achieve copying files one location to other location within time period. Whenever any file reaches to input location, will be copied to output location..
Using transformer content can be transform to other format, process related can be handled by processor and logic can be handled by bean(component)..

Router in Xml Configuration:(applicationContext-camel.xml)
<beans xmlns=""
	xsi:schemaLocation="   ">

	<bean id="processor" class="com.javavillage.camel.processor.LogProcessor"/>
	<bean id="component" class="com.javavillage.camel.transfermor.CamelTranformer"/>

	<camelContext  xmlns="">
			<from uri="file:C:/JavaTraining/camel/input?noop=true" />
			<process ref="processor"/>		
			<bean ref="component"/>			
			<to uri="file:C:/JavaTraining/camel/output" />		

package com.javavillage.camel.processor;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;

public class LogProcessor implements Processor{

	public void process(Exchange exchange) throws Exception {
		String payload = exchange.getIn().getBody(String.class);    
		// do something with the payload and/or exchange here       


Transformer: Retrieving content and changing to uppercase
package com.javavillage.firstcamelprj;

public class Transormer {
	public String transformContent(String body)
		System.out.println("invoking the transformContent method");
		String upperCaseContent=body.toUpperCase();
		return upperCaseContent;


Maven entries for pom.xml




Below is my application execution
package com.javavillage.camel.proj;


 * Hello world!
public class App 
    public static void main( String[] args )
    	AbstractApplicationContext ctx = 
				new ClassPathXmlApplicationContext("applicationContext-camel.xml");

Apache Camel Application Structure

Apache camel Application Structure

Execute Apache Camel Application:

Execution Spring Aspect Application

Paste a file at input location and check console as well output location.We can observe file transfor input folder to output folder