46
Integration Made Easy With Apache Camel Atanas Shindov, Software AG Rosen Spasov, Software AG

Integration made easy with Apache Camel

Embed Size (px)

Citation preview

Integration Made Easy With Apache CamelAtanas Shindov, Software AGRosen Spasov, Software AG

Agenda• What is Apache Camel?• Live Demo• What’s in the box?• Deploying and Testing Camel• Q & A

Agenda• What is Apache Camel?

– Enterprise Integration Patterns– Java and XML DSLs– Architecture

• Live Demo• What’s in the box?• Deploying and Testing Camel• Q & A

What is Apache Camel?

http://camel.apache.org/what-is-camel.html

Apache Camel™ is a versatile open-source integration framework based on known Enterprise Integration Patterns.

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"

Enterprise Integration Patterns

http://www.enterpriseintegrationpatterns.com

● It’s a book

● Contains 65 integration patterns

● Provides a consistent vocabulary and visual notation to describe large-scale integration solutions across many implementation technologies

Enterprise Integration Patterns

http://camel.apache.org/eip

Content Based Router

Content Based Router

from newOrder

Content Based Router

from newOrder choice

Content Based Router

from newOrder choice when isWidget to widget

Content Based Router

from newOrder choice when isWidget to widget otherwise to gadget

Content Based Router

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

Content Based Router

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

Content Based Router

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

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

Content Based Router

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

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

Content Based Router

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)

Content Based Router

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

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

Camel Java DSLimport 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 { from("activemq:queue:newOrder") .choice() .when(xpath("/order/product = 'widget'")) .to("activemq:queue:widget") .otherwise() .to("activemq:queue:gadget") .end(); }}

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>

Camel XML DSL

<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

Camel XML DSL

<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

Camel’s Architecture

Quick Summary● Integration Framework

● Enterprise Integration Patterns (EIP)

● Routing (using DSL)

● Easy Configuration (endpoints as URIs)

● Payload Agnostic

● No Container Dependency

● 120+ Components (connectors)

Agenda• What is Apache Camel?• Live Demo

– File example using Eclipse– Console example– More examples…

• What’s in the box?• Deploying and Testing Camel• Q & A

Live Demo

Console Example

More Examples

http://camel.apache.org/examples

Agenda• What is Apache Camel?• Live Demo• What’s in the box?

– EIP, Components, Data Formats, EL– Domain Specific Languages– Testing and Managing Applications

• Deploying and Testing Camel• Q & A

Predefined Patterns

http://camel.apache.org/eip

What's in the box?● Splitter EIP

120+ Components

19 Data Formats

15 Expression Languages

5+ DSL

● Java DSL

● XML DSL (Spring and OSGi Blueprint)

● Groovy DSL

● Scala DSL

● Kotlin DSL (work in progress)

Test Kit

● camel-test

● camel-test-spring

● camel-test-blueprint

● camel-testng

Web Console - HawtIO

http://hawt.io

What Else?● Interceptors

● Security

● Route Policy

● Type Converters

● Transaction

● Asynchronous non-blocking routing engine

● Thread management

● Maven Tooling... and much, much more

Agenda• What is Apache Camel?• Live Demo• What’s in the box?• Deploying and Testing Camel• Q & A

Deploying Camel● Deployment Strategy

● No Container Dependency

● Lightweight & Embeddable

● Deployment Options

● Standalone

● WAR

● Spring

● JEE, OSGi, Cloud

Java Client Application● No routes required

● Example - upload a file to an FTP server

Author and Contributors

James Strachan Claus Ibsen

What next?

● Buy the “Camel in Action” book

● Visit the web site - camel.apache.org

● Go through the examples

● Experiment…

http://manning.com/ibsen

Q&A

Thank You!

Atanas Shindov

Software Engineer, Software AG