apache-camel

Getting started with apache-camel

Remarks#

Apache Camel is a framework that primarily facilitates solving enterprise integration challenges. At its core it can be thought of as a routing engine engine builder. In essence it allows you to connect systems(endpoints) via routes. These routes accept messages which can be of any data type.

The Apache Camel framework also contains a complete set of EIP(Enterprise integration patterns) such as splitter, aggregators, content based routing and so on. Since the framework can be deployed in various standalone in Java applications, in various application servers such as WildFly and Tomcat or on a fully fledged enterprise service bus it can be seen as a integration framework.

To get started with the framework you would need to add it to a project using one of the following methods:

  1. Maven
  2. Gradle
  3. Spring Boot
  4. Plain Old JAR library reference added to your project.

Installation or Setup

Detailed instructions on adding the required Camel dependencies.


Maven Dependency

One of the most common ways to include Apache Camel in your application is through a Maven dependency. By adding the dependency block below, Maven will resolve the Camel libraries and dependencies for you.

<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-core</artifactId>
  <version>2.17.3</version>
</dependency>

Gradle

Another common way to include Apache Camel in your application is through a Gradle dependency. Simply add the dependency line below and Gradle will import the Camel library and its dependencies for you.

// https://mvnrepository.com/artifact/org.apache.camel/camel-core
compile group: 'org.apache.camel', name: 'camel-core', version: '2.17.3'

Spring Boot

As of Camel 2.15, you can now leverage Apache Camel’s Spring Boot dependency. The difference with this Camel library is that it provides an opinionated auto-configuration, including auto-detection of Camel routes.

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-spring-boot</artifactId>
    <version>${camel.version}</version> <!-- use the same version as your Camel core version -->
</dependency>

Camel Domain Specific Language

Camel’s DSL (Domain Specific Language) is one of the features that makes Camel standout from other Integration frameworks. While some other frameworks also feature a DSL concept, typically in the form of a XML file, the DSL was in such cases always a custom based language.

Camel offers multiple DSLs in programming languages such as Java, Scala, Groovy, and in XML.

For example a simple file copy route can be done in various ways as shown in the list below

  • Java DSL

    from("file:data/in").to("file:data/out");
  • Blueprint/Spring DSL (XML)

    <route>
      <from uri="file:data/inbox"/>
      <to uri="file:data/out"/>
    </route>
  • Scala DSL

    from "file:data/inbox" -> "file:data/out"

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow