54
1 1 Simplify Enterprise Integration With Apache Camel Christian Posta Principal Consultant and Architect 12/16/13

Simplify your integrations with Apache Camel

Embed Size (px)

DESCRIPTION

To build up any non-trivial business processing, you may have to connect systems that are exposed by web-services, fire off events over message queues, notify users via email or social networking, and much more. Apache Camel is a lightweight integration framework that helps you connect systems in a consistent and reliable way. Focus on the business reasons behind what's being integrated, not the underlying details of how.

Citation preview

Page 1: Simplify your integrations with Apache Camel

11

Simplify Enterprise Integration

WithApache Camel

Christian PostaPrincipal Consultant and Architect

12/16/13

Page 2: Simplify your integrations with Apache Camel

2

• What is Integration?

• What is Apache Camel

• Why Apache Camel?

• Example

• Questions?

Agenda

Page 3: Simplify your integrations with Apache Camel

3

Your speakerChristian PostaBlog: http://christianposta.com/blog

Twitter: @christianposta

Email: [email protected]

[email protected]

• Principal Consultant and Architect at Red Hat (FuseSource)

• Based in Phoenix, AZ

• Committer on Apache Camel, ActiveMQ, Apollo

• PMC on ActiveMQ

• Author: Essential Camel Components DZone Refcard

Page 4: Simplify your integrations with Apache Camel

Poll: Estimate how long to implement the following usecase:

Consume XML messages from a queue, call a SOAP webservice if the message is an “alert” message, store data to the file system

Options:

• Less than 1 day

• A few Days

• A few weeks

• A few months

• Cannot be done

4

Page 5: Simplify your integrations with Apache Camel

5 5

What is Integration?

Page 6: Simplify your integrations with Apache Camel

6

Integration?

Page 7: Simplify your integrations with Apache Camel

7

Integration…

Page 8: Simplify your integrations with Apache Camel

8

Just use one computer.

No integration needed.

Page 9: Simplify your integrations with Apache Camel

9

• Off the shelf? Home Grown? Acquisition?

• Platforms

• Protocols / Data Formats

• Data Formats

• Timing

• Organizational mismatch

Why is integration hard?

Page 10: Simplify your integrations with Apache Camel

10

Commercial Solutions?

Page 11: Simplify your integrations with Apache Camel

11

Enterprise Service Bus?

Page 12: Simplify your integrations with Apache Camel

12

Enterprise Service Bus…

Page 13: Simplify your integrations with Apache Camel

13

• Protocol mediation

• Routing

• Transformation

• EIPs

• Start small, build up

• Open Source

• Community driven

Extract the heart of ESB

Page 14: Simplify your integrations with Apache Camel

14

• Common language!!!!!

• Specific context

• Forces at work

• Concrete solution

• Guidance

• Other patterns…

• 65 patterns

Patterns FTW!

Page 15: Simplify your integrations with Apache Camel

1515

What is Apache Camel?

Page 16: Simplify your integrations with Apache Camel

16

Proud parents of Camel

Page 17: Simplify your integrations with Apache Camel

17

Apache CamelApache Camel is an open-source,

light-weight, integration library.

Use Camel to integrate disparate systems

that speak different protocols and data formats

Page 18: Simplify your integrations with Apache Camel

18

• Can carry more weight that other beasts?

• James fancied cigarettes?

• A horse designed by committee?

Why the name Camel?

ConciseApplicationMessagingExchangeLanguage

Page 19: Simplify your integrations with Apache Camel

19

• Light-weight integration library

• Enterprise Integration Patterns

• Components

• Domain Specific Language

• Routing and Mediation (like an ESB?)

• Runs in any container (or stand alone)

What is Apache Camel?

Page 20: Simplify your integrations with Apache Camel

20

• An integration library• Routing (content-based, dynamic, rules-engine…)

• Mediation (xformations, protocols, wire transports…)

• DSL

• Can build an ESB (real ESB.. Not just box in the middle)

• Many options based on Camel!• Fuse ESB / JBoss Fuse

• Apache ServiceMix (Karaf + Camel)

• Talend, wso2, others…

• Not tied to vendor lock-in and commercial licenses!

Not an ESB…per-se…

Page 21: Simplify your integrations with Apache Camel

21

Very popular

• Used at top companies in finance, shipping,

retail/e-retail, health care, airline

reservations, etc

• E*Trade: http://goo.gl/FDqgpV

• Sabre: http://goo.gl/RrWcQ5

• CERN: http://goo.gl/vEO7zR

Page 22: Simplify your integrations with Apache Camel

22

Open source

• Apache Software Foundation

• ASL v 2.0 Licensed

• Vibrant community

• Jira, mailing list, github

• Lots of contributions! Check out the components!

Page 23: Simplify your integrations with Apache Camel

2323

Quick Example

Page 24: Simplify your integrations with Apache Camel

24

Quick Example

File System Message Oriented Middleware

Page 25: Simplify your integrations with Apache Camel

25

Quick Example

From A Send to BFilter message

Page 26: Simplify your integrations with Apache Camel

26

Quick Example

from(A) to(B)filter(predicate)

Page 27: Simplify your integrations with Apache Camel

27

Quick Example

from(A) .to(B).filter(isWidget)

Page 28: Simplify your integrations with Apache Camel

28

Quick Example

isWidget = xpath(“/quote/product = ‘widget’”);

from(A) .filter(isWidget). to(B)

Page 29: Simplify your integrations with Apache Camel

2929

Using Camel

Page 30: Simplify your integrations with Apache Camel

30

Pipes and Filters

• Step by Step – “Processors” in Camel terminology

• Complex processing – “Routes”

• Flexible

• Testing

• Reuse

Page 31: Simplify your integrations with Apache Camel

31

• Defined in Java, XML, Scala, Groovy

• Step by step processing of a message:

• Consumer – Listen for incoming message

• Zero or more “filters” or Processors

• Producer – Send outgoing message

• Number of processing filters, or “Processors” in Camel-speak

• EIPs

• Tranform, redirect, enrich

Camel Routes

Page 32: Simplify your integrations with Apache Camel

32

Domain Specific Language

• Domain specific (integration)

• Used to build and describe Camel Routes

• Embedded within a general programming language

• Java, Spring XML, Scala, Groovy

• Take advantage of existing tools

• Fluent builders (builder pattern…)• from(“..”).enrich(“…”).filter(“..”).to(“…”);

Page 33: Simplify your integrations with Apache Camel

33

Java DSLpublic class OrderProcessorRouteBuilder extends RouteBuilder {

@Override public void configure() throws Exception {

from(“activemq:orders”).choice()

.when(header(“customer-rating”).isEqualTo(“gold”)) .to(“ibmmq:topic:specialCustomer”) .otherwise() .to(“ftp://user@host/orders/regularCustomers”) .end() .log(“received new order ${body.orderId}”) .to(“ibatis:storeOrder?statementType=Insert”); }}

Page 34: Simplify your integrations with Apache Camel

34

Spring XML DSL        <route id=“processOrders”>

            <from uri=“activemq:orders”/>

<choice>

<when>

<simple>${header.customer-rating} == ‘gold’</simple>

<to uri=“ibmmq:topic:specialCustomer”>

</when>

<otherwise>

<to uri=“ftp://user@host/orders/regularCustomers” />

</otherwise>

</choice>

<log message=“received new order ${body.orderId}”/>

            <to uri=“ibatis:storeOrder?statementType=Insert”/>

        </route>

Page 35: Simplify your integrations with Apache Camel

35

• Message Routing

• Transformation

• Aggregation

• Splitting

• Resequencer

• Routing Slip

• Enricher

• All 65 from the book!

Enterprise Integration Patterns

Page 36: Simplify your integrations with Apache Camel

36

• Prepackaged bits of code

• Highly configurable

• Maximum interoperability

• Used to build “Adapters” to existing systems

• Don’t reinvent the wheel and end up with a box

Components

Page 37: Simplify your integrations with Apache Camel

37

Components

• ActiveMQ, Websphere, Weblogic (JMS)

• AMQP

• ATOM feeds

• AWS (S3, SQS, SNS, others)

• Bean

• Cache (EHCache)

• CXF (JAX-WS, JAX-RS)

• EJB

• Drools

• File

• FTP

• Google App Engine

• GMail

• HTTP

• IRC

• jclouds

• JDBC

• Jetty

• Twitter

• MQTT

• MyBatis

• JPA

• Spring Integration

• Spring Web Services

http://camel.apache.org/components.html

To see list of all

components!!

Page 38: Simplify your integrations with Apache Camel

38

• URI format:• scheme:localPart[?options]

• scheme: identifies the “component”

• localPart: specific to the component

• options: is a list of name-value pairs

• Creates endpoints based on configuration

• Route endpoint “factories”

• Integrate with Camel Routes by creating producer/consumer endpoints

Components

from(“aws-sqs://demo?defaultVisibilityTimeout=2”)

Page 39: Simplify your integrations with Apache Camel

39

Another Example

public class MyExampleRouteBuilder extends RouteBuilder {

@Override public void configure() throws Exception {

from(“aws-sqs://demo?defaultVisibilityTimeout=2”)

.setHeader(“type”).jsonpath(“$[‘type’]”)

.filter(simple(“${header.type} == ‘login’”)

.to(“jms:quote”); }}

Page 40: Simplify your integrations with Apache Camel

40

Test Framework• Powerful way to test your Camel routes

• http://camel.apache.org/mock.html

• Uses Mocks

• Mocks vs Stubs? • http://martinfowler.com/articles/mocksArentStubs.html

• Provides declarative testing mechanism

• Declare

• Test

• Assert

Page 41: Simplify your integrations with Apache Camel

41

Management with HawtIO

http://hawt.io

Page 42: Simplify your integrations with Apache Camel

42

Developer Tooling Support

Fuse IDE

Page 43: Simplify your integrations with Apache Camel

43

JBoss Fuse (aka Fuse ESB)Integrate Everything!

Page 44: Simplify your integrations with Apache Camel

44

More info on JBoss Fuse…

https://www.redhat.com/products/jbossenterprisemiddleware/fuse/

http://www.jboss.org/products/fuse

Page 45: Simplify your integrations with Apache Camel

4545

Live Demo

Page 46: Simplify your integrations with Apache Camel

4646

Resources

Page 47: Simplify your integrations with Apache Camel

47

Presentation Resources

Page 48: Simplify your integrations with Apache Camel

48

Professional TrainingCamel Development

with Red Hat JBoss Fuse (Online Training)

http://www.redhat.com/training/courses/jb421r/

Red Hat JBoss A-MQ

Development and Deployment (Online Training)

https://www.redhat.com/training/courses/jb437r/

Red Hat Certificate of

Expertise in Camel Development

http://www.redhat.com/training/certifications/jbcd-camel-development/

Page 49: Simplify your integrations with Apache Camel

49

Dzone Refcardz

• Camel Essential Components • http://refcardz.dzone.com/refcardz/essential-camel-components

• Essential EIP with Apache Camel• http://refcardz.dzone.com/refcardz/enterprise-integration

REFCARDZ

Page 50: Simplify your integrations with Apache Camel

50

Apache Community• http://camel.apache.org

• Mailing list: [email protected]

• Nabble Archive: http://camel.465427.n5.nabble.com/Camel-Users-f465428.html

• Source code: https://git-wip-us.apache.org/repos/asf?p=camel.git

• Blogs, Articles, Examples• http://www.davsclaus.com

• http://www.christianposta.com/blog

• http://www.ossmentor.com/

• http://camel.apache.org/articles.html

• http://camel.apache.org/user-stories.html

• http://camel.apache.org/user-stories.html

Page 51: Simplify your integrations with Apache Camel

51

Apache Camel Books

Page 52: Simplify your integrations with Apache Camel

52

Apache Camel Books

Page 53: Simplify your integrations with Apache Camel

53

Apache Camel Books

Page 54: Simplify your integrations with Apache Camel

5454

QuestionsQuestions