Templates by BIGtheme NET

Introduction to Camel

Description
1) Camel is an integration framework that aims to make your integration projects productive
and fun. Camel’s focus is on simplifying integration.
2) The core of the Camel framework is a routing engine, or more precisely a routingengine
builder.
3) It allows you to define your own routing rules, decide from which sources to accept messages,
and determine how to process and send those messages to other destinations.
4) Camel uses an integration language that allows you to define complex routing rules, akin to business processes.
5) One of the fundamental principles of Camel is that it makes no assumptions about the type
of data you need to process
.
This is an important point, because it gives you, the developer, an opportunity to integrate any kind of system, without the need to convert your data to a canonical format.
6) Camel isn’t an enterprise service bus (ESB), although some call Camel a lightweight ESB because of its support for routing, transformation, monitoring, orchestration, and so forth.

File Transfer using Camel :
Steps to be followed:
1) Download camel from http://camel.apache.org/download.html
In case of maven2, you can mentioned as

org.apache.camel
camel-core
2.15.1

2) Code And Run
3) Demo

FileTransferByCamel.java

package com.venkatjavasource.camel;

import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;

public class FileTransferByCamel {

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		CamelContext context = new DefaultCamelContext();
		try {
		context.addRoutes(new RouteBuilder() {
            public void configure() {
                from("file:/venkatjavasource/camel/from?noop=true").to("file:/venkatjavasource/camel/to");
            }
        });
        context.start();                
        Thread.sleep(2000);
		} finally {
			System.out.println("Before stop camel context ...");
			context.stop();
		}
	}
}

Here we configured from and to end points.
Here in from end point from(“file:/venkatjavasource/camel/from?noop=true”),
noop=true means, keep the original files in source directory.

The source directories before running FileTransferByCamel.java class, there are two files File 1.txt and File 2.txt in source folder C:venkatjavasourcecamelfrom)
1

And the destination is not having any files,
2
Run the application :
Right click on java source and click “Run As” -> “Java Application”

The the two files will copied to destination directory, C:venkatjavasourcecamelfrom)
3

Still the original files will be there in source directory, C:venkatjavasourcecamelfrom)

If in case of noop=false, the original files will be removed from source directory and backup will be created in the same source directory.

public void configure() {
      from("file:/venkatjavasource/camel/from?noop=false").to("file:/venkatjavasource/camel/to");
}

The original files are removed from source directory,
5

But .camel directory is created to keep the backup.
4