Getting started with Apache Camel - jDays 2013

70
PUBLIC PRESENTATION | CLAUS IBSEN 1 Getting started with Apache Camel Claus Ibsen (@davsclaus) Principal Software Engineer, Red Hat jdays.se, november 2013

description

In this session will teach you how to get a good start with Apache Camel. We will introduce you to Apache Camel and how Camel its related to Enterprise Integration Patterns. And how you go about using these patterns in Camel routes, written in Java code or XML files. We will then discuss how you can get started developing with Camel, and how to setup new projects from scratch using Maven and Eclipse tooling. This session includes live demos that show how to build Camel applications in Java, Spring, OSGi Blueprint and alternative languages such as Scala and Groovy. You will also hear what other features Camel provides out of the box, which can make integration much easier for you. We also take a moment to look at hawtio, then hot new web console tooling that allows you to get insight into your running Apache Camel applications, which has among others visual route diagrams with tracing/debugging and profiling capabilities. Before opening up for QA, we will share useful links where you can dive into learning more about Camel.

Transcript of Getting started with Apache Camel - jDays 2013

Page 1: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN1

Getting started with Apache Camel

Claus Ibsen (@davsclaus)Principal Software Engineer, Red Hatjdays.se, november 2013

Page 2: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN2

Your Speaker

● Principal Software Engineer at Red Hat

● Apache Camel● 5 years working full-time with Camel

● Author of Camel in Action book

● Contact● EMail: [email protected]● Twitter: @davsclaus● Linkedin: davsclaus● Blog: http://davsclaus.com

Page 3: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN3

Agenda

● What is Apache Camel?

● A little Example

● Riding Camel

● What's in the Camel box?

● Deploying Camel

● Creating new Camel Projects

● Hawtio – Camel Tooling

● Q and A

Page 4: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN4

What is Apache Camel?

● Quote from the website

Page 5: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN5

What is Apache Camel?

● Why do we need integration?● Critical for your business to integrate

● Why Integration Framework?● Framework do the heavy lifting● You can focus on business problem● Not "reinventing the wheel"

Page 6: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN6

What is Apache Camel?

● What is Enterprise Integration Patterns?

It's a book

Page 7: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN7

What is Apache Camel?

● Enterprise Integration Patterns

http://camel.apache.org/eip

Page 8: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN8

What is Apache Camel?

● EIP - Content Based Router

Page 9: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN9

What is Apache Camel?

from newOrder

Page 10: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN10

What is Apache Camel?

from newOrder choice

Page 11: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN11

What is Apache Camel?

from newOrder choice when isWidget to widget

Page 12: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN12

What is Apache Camel?

from newOrder choice when isWidget to widget otherwise to gadget

Page 13: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN13

What is Apache Camel?

from(newOrder) choice when(isWidget) to(widget) otherwise to(gadget)

Page 14: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN14

What is Apache Camel?

from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);

Page 15: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN15

What is Apache Camel?

Endpoint newOrder = endpoint("activemq:queue:newOrder");

from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);

Page 16: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN16

What is Apache Camel?

Endpoint newOrder = endpoint("activemq:queue:newOrder");Predicate isWidget = xpath("/order/product = 'widget'");

from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);

Page 17: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN17

What is Apache Camel?

Endpoint newOrder = endpoint("activemq:queue:newOrder");Predicate isWidget = xpath("/order/product = 'widget'");Endpoint widget = endpoint("activemq:queue:widget");Endpoint gadget = endpoint("activemq:queue:gadget");

from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);

Page 18: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN18

What is Apache Camel?

● Java Code

public void configure() throws Exception { Endpoint newOrder = endpoint("activemq:queue:newOrder"); Predicate isWidget = xpath("/order/product = 'widget'"); Endpoint widget = endpoint("activemq:queue:widget"); Endpoint gadget = endpoint("activemq:queue:gadget");

from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget) .end(); }

Page 19: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN19

What is Apache Camel?

● Java Codeimport org.apache.camel.Endpoint;import org.apache.camel.Predicate;import org.apache.camel.builder.RouteBuilder;

public class MyRoute extends RouteBuilder {

public void configure() throws Exception { Endpoint newOrder = endpoint("activemq:queue:newOrder"); Predicate isWidget = xpath("/order/product = 'widget'"); Endpoint widget = endpoint("activemq:queue:widget"); Endpoint gadget = endpoint("activemq:queue:gadget");

from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget) .end(); }}

Page 20: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN20

What is Apache Camel?

● Camel Java DSL

import org.apache.camel.builder.RouteBuilder;

public class MyRoute extends RouteBuilder {

public void configure() throws Exception { from("activemq:queue:newOrder") .choice() .when(xpath("/order/product = 'widget'")) .to("activemq:queue:widget") .otherwise() .to("activemq:queue:gadget") .end(); }}

Page 21: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN21

What is Apache Camel?

● Camel XML DSL

<route> <from uri="activemq:queue:newOrder"/> <choice> <when> <xpath>/order/product = 'widget'</xpath> <to uri="activemq:queue:widget"/> </when> <otherwise> <to uri="activemq:queue:gadget"/> </otherwise> </choice> </route>

Page 22: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN22

What is Apache Camel?

● Endpoint as URIs

<route> <from uri="file:inbox/orders"/> <choice> <when> <xpath>/order/product = 'widget'</xpath> <to uri="activemq:queue:widget"/> </when> <otherwise> <to uri="activemq:queue:gadget"/> </otherwise> </choice> </route>

use file instead

Page 23: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN23

What is Apache Camel?

● Endpoint as URIs

<route> <from uri="file:inbox/orders?delete=true"/> <choice> <when> <xpath>/order/product = 'widget'</xpath> <to uri="activemq:queue:widget"/> </when> <otherwise> <to uri="activemq:queue:gadget"/> </otherwise> </choice> </route>

parameters

Page 24: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN24

What is Apache Camel?

● Camel's Architecture

Page 25: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN25

What is Apache Camel?

120+ Components

Page 26: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN26

What is Apache Camel?

120+ Components

Page 27: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN27

What is Apache Camel?

● Summary● Integration Framework● Enterprise Integration Patterns (EIP)● Routing (using DSL)● Easy Configuration (endpoint as uri's)● No Container Dependency● A lot of components

Page 28: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN28

Agenda

● What is Apache Camel?

● A little Example

● Riding Camel

● What's in the Camel box?

● Deploying Camel

● Creating new Camel Projects

● Hawtio – Camel Tooling

● Q and A

Page 29: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN29

A Little Example

● File Copier Example

Page 30: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN30

A Little Example

● File Copier Example

Page 31: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN31

A Little Example

● File Copier Example

Page 32: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN32

A Little Example

● File Copier Example

Page 33: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN33

A Little Example

● File Copier Example

Page 34: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN34

Agenda

● What is Apache Camel?

● A little Example

● Riding Camel

● What's in the Camel box?

● Deploying Camel

● Creating new Camel Projects

● Hawtio – Camel Tooling

● Q and A

Page 35: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN35

Riding Camel

● Downloading Apache Camel● zip/tarball (approx 8mb)

http://camel.apache.org

Page 36: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN36

Riding Camel

● Using Command Shell● Requires:

Apache Maven

● From Eclipse

Page 37: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN37

Riding Camel

● Console Example

● cd examples/camel-example-console

● mvn compile exec:java

Page 38: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN38

Riding Camel

● Twitter Example

● cd examples/camel-example-twitter-websocket

● mvn compile exec:java http://localhost:9090/index.html

Page 39: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN39

Riding Camel

● More examples ...

... and further details at website.

http://camel.apache.org/examples

Page 40: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN40

Agenda

● What is Apache Camel?

● A little Example

● Riding Camel

● What's in the box?

● Deploying Camel

● Creating new Camel Projects

● Hawtio – Camel Tooling

● Q and A

Page 41: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN41

What's in the box?

Page 42: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN42

What's in the box?

● Enterprise Integration Patterns

http://camel.apache.org/eip

Page 43: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN43

What's in the box?

● Splitter EIP

Page 44: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN44

What is Apache Camel?

120+ Components

Page 45: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN45

What is Apache Camel?

19 Data Formats

Page 46: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN46

What is Apache Camel?

15 Expression Languages

Page 47: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN47

What is Apache Camel?

5+ DSL in multiple languages● Java DSL● XML DSL (Spring and OSGi Blueprint)● Groovy DSL● Scala DSL● Kotlin DSL (work in progress)

Page 48: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN48

What is Apache Camel?

Test Kit● camel-test camel-test-spring● camel-test-blueprint camel-testng

Page 49: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN49

What is Apache Camel?

Management● JMX● REST (w/ Jolokia)

Page 50: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN50

What is Apache Camel?

Tooling – Web console - HawtIO

http://hawt.io

Page 51: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN51

What is Apache Camel?

Tooling – Eclipse Plugin – Fuse IDE

http://github.com/fusesource/fuseide

Page 52: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN52

What is Apache Camel?

Error Handling

Page 53: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN53

What is Apache Camel?

try .. catch style

Page 54: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN54

What is Apache Camel?

Dead Letter Channel (EIP style)

Page 55: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN55

Agenda

● What is Apache Camel?

● A little Example

● Riding Camel

● What's in the Camel box?

● Deploying Camel

● Creating new Camel Projects

● Hawtio – Camel Tooling

● Q and A

Page 56: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN56

Deploying Camel

● Deployment Strategy● No Container Dependency● Lightweight & Embeddable

● Deployment Options● Standalone● WAR● Spring● JEE● OSGi● Cloud

Page 57: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN57

Camel as a Client

● Java Client Application (no routes)

● Example● Upload a file to a FTP server

Page 58: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN58

Agenda

● What is Apache Camel?

● A little Example

● Riding Camel

● What's in the Camel box?

● Deploying Camel

● Creating new Camel Projects

● Hawtio – Camel Tooling

● Q and A

Page 59: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN59

Creating new Camel Projects

● Using Command Shell

● From Eclipse

Page 60: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN60

Creating new Camel Projects

● Maven Archetypes

Page 61: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN61

Creating new Camel Projects

● camel-archetype-blueprint

Page 62: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN62

Creating new Camel Projects

● Importing into Eclipse

Existing Maven Project

Page 63: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN63

Agenda

● What is Apache Camel?

● A little Example

● Riding Camel

● What's in the Camel box?

● Deploying Camel

● Creating new Camel Projects

● Hawtio – Camel Tooling

● Q and A

Page 64: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN64

Hawtio – Camel Tooling

http://hawt.io

Page 65: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN65

Agenda

● What is Apache Camel?

● A little Example

● Riding Camel

● What's in the Camel box?

● Deploying Camel

● Creating new Camel Projects

● Hawtio – Camel Tooling

● Q and A

Page 66: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN66

Where do I get more information?

● Best Article covering what Apache Camel is● http://java.dzone.com/articles/open-source-integration-

apache

Link to article from “Getting Started”

Page 67: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN67

Where do I get more information?

● Try Camel Examples● http://camel.apache.org/examples.html

● Read other blogs and articles● http://camel.apache.org/articles.html

● Use the “search box” on the Camel front page

Page 68: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN68

Where do I get more information?

● Use the mailing list / forum● http://camel.apache.org/mailing-lists.html

● Use stackoverflow● http://stackoverflow.com/questions/tagged/apache-camel

Page 69: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN69

Where do I get more information?

● Buy the Camel in Action book

http://manning.com/ibsen/

Use code ...camel40

… for 40% discount

Page 70: Getting started with Apache Camel - jDays 2013

PUBLIC PRESENTATION | CLAUS IBSEN70

Any Questions ?

● Contact● EMail: [email protected]● Twitter: @davsclaus● Linkedin: davsclaus● Blog: http://davsclaus.com