Search Tutorials

Apache Camel Using Java DSL Hello World | JavaInUse

Apache Camel Using Java DSL using Hello World

In this tutorial we will create a simple application to get started with Apache Camel using Java DSL.

Apache Camel - Table of Contents

File Transfer Using Java DSL Apache Camel Apache Camel Java DSL + Spring Integration Hello World Example Apache Camel Exception Handling Using Simple Example Apache Camel Redelivery policy using example Integrate Apache Camel and ActiveMQ EIP patterns using Apache Camel Apache Camel Tutorial- Integrate Spring Boot+ Apache Camel Apache Camel Tutorial- Integrate with MySQL DB using SQL query Apache Camel EIP - Splitter and Aggregator pattern Apache Camel Unit Testing Apache Camel + Spring + Quartz Hello World Example Camel application deployment on JBoss Fuse Apache Camel + Apache CXF SOAP Webservices Apache Camel + JAX-RS REST Webservice Apache Camel + CXFRS REST Webservice Apache Camel Routing Slip EIP Pattern Apache Camel Dynamic Router Pattern Apache Camel Load Balancer EIP Pattern Apache Camel Interceptors Apache Camel + Kafka Hello World Example Apache Camel - Marshalling/Unmarshalling XML/JSON Data Example Calling and Consuming Webservices using Apache Camel Apache Camel Tutorial - Send SMTP Email Using Gmail Apache Camel Tutorial - SEDA component Hello World Example Spring Boot + Apache Camel + RabbitMQ - Hello World Example Apache Camel Tutorial - Idempotent Consumer using MemoryIdempotentRepository and FileIdempotentRepository Spring Boot + Apache Camel JDBC component + MySQL - Hello World Example Spring Boot + Apache Camel SQL component + MySQL - Hello World Example Spring Boot + Apache Camel SQL component + Transaction Management Example


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.
We will create Eclipse maven project as follows-

Apache Camel File Copy Tutorial
Our pom file will be as follows-
<project xmlns="" xmlns:xsi=""


Next we create a class to construct a camel route. A Route is like an instruction definition to Camel on how to move your messages from one point to another. We are going to create class that will move files from c://inputFolder to c://outputFolder.
Also here during the transfer from source folder we have written noop=true, this tells 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).
If noop=true, Camel will set idempotent=true as well, to avoid consuming the same files over and over again.
package com.javainuse;

import org.apache.camel.builder.RouteBuilder;

public class SimpleRouteBuilder extends RouteBuilder {

    public void configure() throws Exception {


When Camel is started, it creates a CamelContext object that contains the definition of the Route to be started. Below we create default camel context and load the route created in SimpleRouteBuilder.
package com.javainuse;

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

public class MainApp {

    public static void main(String[] args) {
        SimpleRouteBuilder routeBuilder = new SimpleRouteBuilder();
        CamelContext ctx = new DefaultCamelContext();
        try {
            Thread.sleep(5 * 60 * 1000);
        catch (Exception e) {


Run this Any file in C:inputfolder will get copied to C://outputFolder.
Below we copy the employee-management-system.war to C:inputfolder.
Apache Camel File Transfer Example
Our camel application copies the file to C://outputFolder.
Apache Camel Java DSL File Copy Example

Download Source Code

Download it - Apache Camel Java DSL Hello World

See Also

Spring Boot Hello World Application- Create simple controller and jsp view using Maven Spring Boot Tutorial-Spring Data JPA Spring Boot + Simple Security Configuration Pagination using Spring Boot Simple Example Spring Boot + ActiveMQ Hello world Example Spring Boot + Swagger Example Hello World Example Spring Boot + Swagger- Understanding the various Swagger Annotations Spring Boot Main Menu Spring Boot Interview Questions