Integration using Apache Camel and Groovy

Embed Size (px)

Citation preview

Claus Ibsen

Red Hat

Integration using
Apache Camel & Groovy

Your Speaker

Principal Software Engineer at Red Hat

Apache Camel6 years as committer

Author of Camel in Action book

ContactEMail: [email protected]

Twitter: @davsclaus

Blog: http://davsclaus.com

Linkedin: http://www.linkedin.com/in/davsclaus

This awesome ...

These two awesome has ...

These three awesome has ...

These three awesome has something in common

Agenda

What is Apache Camel?

A little Example

Riding Camel

Creating new Camel Projects

hawtio

Q & A

Why the name Camel?

Why the name Camel?

Because Camel is
easy to remember and type ...

Why the name Camel?

or the creator used to smoke cigarets!

http://camel.apache.org/why-the-name-camel.html

What is Apache Camel?

Quote from the website

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"

What is Apache Camel?

What is Enterprise Integration Patterns?

It's a book

What is Apache Camel?

Enterprise Integration Patterns

http://camel.apache.org/eip

What is Apache Camel?

EIP - Content Based Router

What is Apache Camel?

from newOrder

What is Apache Camel?

from newOrder choice

What is Apache Camel?

from newOrder choice when isWidget to widget

What is Apache Camel?

from newOrder choice when isWidget to widget otherwise to gadget

What is Apache Camel?

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

What is Apache Camel?

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

What is Apache Camel?

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

Ups Sorry ...This is a gr8confso lets get Groovy :)

What is Apache Camel?

from newOrder choice when isWidget to widget otherwise to gadget

What is Apache Camel?

from newOrder choice when isWidget to widget otherwise to gadget

Unfortunately the Camel Groovy DSL is not as awesome yet

What is Apache Camel?

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

We removed that last semi colon ;)

What is Apache Camel?

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

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

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);

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);

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(); }

What is Apache Camel?

Java Code

import 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(); }}

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(); }}

What is Apache Camel?

Camel XML DSL

/order/product = 'widget'

What is Apache Camel?

Endpoint as URIs

/order/product = 'widget'

use file instead

What is Apache Camel?

Endpoint as URIs

/order/product = 'widget'

parameters

Standard Java, XML, or Groovy

Java DSL is just Java

Standard Java, XML, or Groovy

XML DSL is just XML








with XSD schema for validation/tooling

Standard Java, XML, or Groovy

Groovy DSL is just Groovy

GroovyClosure

What is Apache Camel?

Camel's Architecture

What is Apache Camel?

150+ Components

What is Apache Camel?

150+ Components

What is Apache Camel?

SummaryIntegration Framework

Enterprise Integration Patterns (EIP)

Routing (using DSL)

Easy Configuration (endpoint as uri's)

Just Java, XML, or Groovy code

No Container Dependency

A lot of components

Agenda

What is Apache Camel?

A little Example

Riding Camel

Creating new Camel Projects

hawtio

Q & A

A Little Example

File Copier Example

A Little Example

File Copier Example

A Little Example

File Copier Example

A Little Example

File Copier Example

A Little Example

File Copier Example

A Little Groovy Example

A Little Groovy Example (all source)

A Little Groovy Example

Run the examplegroovy mycamel.groovy

Agenda

What is Apache Camel?

A little Example

Riding Camel

Creating new Camel Projects

hawtio

Q & A

Riding Camel

Downloading Apache Camelzip/tarball (approx 8mb)

http://camel.apache.org

Riding Camel

Using Command ShellRequires: Apache Maven




From Eclipse

Riding Camel

Console Example






cd examples/camel-example-console

mvn compile exec:java

Riding Camel

Twitter Example






cd examples/camel-example-twitter-websocket

mvn compile exec:java

http://localhost:9090/index.html

Riding Camel

More examples ...






... and further details at website.

http://camel.apache.org/examples

Agenda

What is Apache Camel?

A little Example

Riding Camel

Creating new Camel Projects

hawtio

Q & A

Creating new Camel Projects

Using Command Shell



.. or from Eclipse

Creating new Camel Projects

Importing into Eclipse

Existing Maven Project

Creating new Camel Projects

Maven Archetypes

camel-archetype-activemqcamel-archetype-java

camel-archetype-blueprintcamel-archetype-scala

camel-archetype-componentcamel-archetype-spring

camel-archetype-dataformatcamel-archetype-spring-dm

camel-archetype-groovycamel-archetype-web

Creating new Camel Projects

camel-archetype-groovy

mvn installmvn exec:java

Creating new Camel Projects

camel-archetype-spring

mvn installmvn camel:runmvn io.hawt:hawtio-maven-plugin:1.4.2:spring

Agenda

What is Apache Camel?

A little Example

Riding Camel

Creating new Camel Projects

hawtio

Q & A

hawtio

What does it do? ...

hawtio

Yet another awesome project created by this guy ...

hawtio

Tooling Web Console - hawtio

http://hawt.io

hawtio

What does it do
for Apache Camel?

hawtio

Technology StackHTML5 single page app

TypeScript JavaScript

Angular JS

Bootstrap CSS

HTTP/REST backend

Jolokia on backend for JMX over REST

Plugins expose services as JMX or REST

http://hawt.io/plugins/howPluginsWork.html

Apache Camel & hawtio

Agenda

What is Apache Camel?

A little Example

Riding Camel

Creating new Camel Projects

hawtio

Q & A

These three awesome has something in common

These three awesome has something in common

What about a 4th awesome project?

Any Questions ?

ContactEMail: [email protected] / [email protected]

Twitter: @davsclaus

Blog: http://davsclaus.com

Linkedin: http://www.linkedin.com/in/davsclaus

Click to edit the title text format

Click to edit the outline text format

PUBLIC PRESENTATION | CLAUS IBSEN

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline LevelNinth Outline Level