Building a Camel route to JPA

In this tutorial we will learn how to persist some data on a Database using a Camel route which is based on the Java Persistence API defined in a project. The steps to complete this tutorial are: Let’s start from a maven archetype Create the entity bean Configure the persistence.xml Configure the camel-context Define the … Read more

Basic Camel Architecture tutorial

This tutorial provides an overview of Camel architecture components. The Camel architecture consists of: CamelContext: This represents an instance of the Camel runtime environment running in a JVM. it represents a single Camel routing rulebase and works in a similar way to the Spring ApplicationContext. End points: They represent a message producer or consumer used … Read more

Basic Enterprise Integration Patterns with Camel

Camel supports most of the Enterprise Integration Patterns (EIP). Basically EIP provide a way to integrate Enterprise applications by means of messaging. We will go through the most common types of Integration Patterns. Router A content-based router allows dynamic routing depending on the content of a message. It can handle multiple messages from the same … Read more

Transforming CSV to Java Objects using Camel

This tutorial shows how to perform a simple transformation from CSV to Java objects with Camel using as destination a processor or a JMS Queue. First of all, we will define a class mapping our CSV file. package com.sample.model; import java.io.Serializable; import org.apache.camel.dataformat.bindy.annotation.CsvRecord; import org.apache.camel.dataformat.bindy.annotation.DataField; @CsvRecord(separator = “,”) public class User implements Serializable { @DataField(pos … Read more

Using the Timer Component with Camel

The Timer component is used to generate message exchanges when a timer fires. The Timer is a simple, non persistence timer using the JDK’s in built timer mechanism. package com.sample; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.spi.DataFormat; public class Timer { public static void main(String args[]) throws Exception { CamelContext … Read more

Using Camel JDBC Component

In this tutorial we will learn how to perform some basic JDBC operations using Camel JDBC Component. The JDBC component enables you to access databases through JDBC, where SQL queries (SELECT) and operations (INSERT, UPDATE, etc) are sent in the message body. This component uses the standard JDBC API. In the following example, we will … Read more

Using Camel Stream Component

The stream Camel component provides access to the System.in, System.out and System.err streams as well as allowing streaming of file and URL. When using the stream component, the following URI syntax is available: stream:in[?options] stream:out[?options] stream:err[?options] stream:header[?options] In the following example, we are using the stream:out to perform a System.out of the content of files … Read more

Using Camel direct Component

In Camel the direct: component provides direct, synchronous invocation of any consumers when a producer sends a message exchange. it provides a simple mechanism for linking together routes just like in programming code you would call functions. For example consider the following route: CamelContext context = new DefaultCamelContext(); context.addRoutes(new RouteBuilder() { public void configure() { … Read more

Using Camel in Nashorn shell

In this tutorial we are going to play with nashorn and camel to create a very interesting mix. Nashorn is the javascript engine shipped with the last release of jdk: 8. Using Nashorn it’s possible to launch shell script using java. You can launch nashorn typing: > /usr/java/jdk1.8.0_31/bin/jjs or > jjs Nashorn works like any … Read more

Using the Bean component in Camel

The Bean component can be used as part of a camel route to filter/intercept the payload of data contained in the route. Let’s see a very simple example. The purpose of this example is to convert money contained in a text file from Dollars to Euros. The beans that will do the job is MoneyConverter … Read more