enterprise integration patterns with apache camel

52
Enterprise Integration Patterns with Apache Camel Ioan Eugen Stan 20 Septembrie 2013 Axway Kickoff

Upload: ioan-stan

Post on 07-Nov-2014

2.774 views

Category:

Technology


13 download

DESCRIPTION

Enterprise integration patterns, Apache Camel, EIP

TRANSCRIPT

Enterprise Integration Patterns

withApache Camel

Ioan Eugen Stan20 Septembrie 2013

Axway Kickoff

● Why = The purpose - What is you cause? What do you belive in?

● How = The Process - specifc

actions taken to realize the Why

● What = The result - what do you do, the result of Why. Proof.

TED, Simon Sinek, May 2010

Why do we need integration?

A integra = include, a (se) îngloba, a (se) încorpora, a (se) armoniza într-un tot.

Why EIP Where does complexity come from?

Much of the complexity stems from two issues:● dealing with the specifics of applications and

transports ● coming up with good solutions to integration

problems

The Book

● 65 design patterns● Formalized language● Covers:

○ Integration Styles○ Messaging Systems○ Message Construction○ Message Routing○ Message Transformation○ Messaging Endpoints○ System Management

EIPs in detail (1)

Message

Pipes and Filters

Message translator

Message router

Messaging Systems

EIPs in detail (2)

Point to Point channel

Publish Subscribe Channel

Dead letter queue

Guaranteed delivery

Messaging Channels

EIPs in detail (3)

Event message

Request reply

Correlation identifier

Return Address

Messaging Construction

EIPs in detail (4)

Content based router

Message filter

Dynamic router

Recipient list

Messaging Routing

EIPs in detail (5)

Splitter

Aggregator

Resequencer

Routing slip

Messaging Routing

EIPs in detail (6)

Content enricher

Content filter

Claim check

Normalizer

Messaging Transformation

EIPs in detail (7)

Event driven consumer

Pooling consumer

Transactional client

Service activator

Messaging Endpoints

EIPs in detail (8)

Control bus

Detour

Wire Tap

System Management

Flight Mash-up

Image from: http://appzdevelop.blogspot.ro/2012/02/apache-camel-flight-aggregation-mashup.html

Code: https://code.google.com/p/apache-camel-mashup/

Purchase example

Normalization

Transform multiple message types into a common format

Other examples

Apache Camel

● java framework for integration and mediation● rules in multiple DSLs:

○ Fluent Java○ Spring XML○ Blueprint XML○ Scala

● over > 150 out-of-box components ● bean binding and integration with popular

frameworks● active comunity ~ 900 messages/month

Camel Architecture

Image from: http://java.dzone.com/articles/open-source-integration-apache (Camel in Action)

Basics

● create a CamelContext● optionally configure components or

endpoints● add routing rules● start the context

Example Java DSL

Example Spring DSL

Vocabulary: Component & Endpoint

● Component is an Endpoint factory● Enpoints are refered by URIs: file://, jms://● Has methods:

○ createProducer() ○ createConsumer() ○ createPoolingConsumer()

(Some) Standard components

● AHC - Async HTTP client

● Atom

● AMPQ

● AWS-* - Amazon cloud services

● Bean - Bean binding

● DNS - DNS look-up

● Elasticsearch

● JPA● File & FTP● HBase

● HTTP● LDAP

● MongoDB

● Mustache

● Netty

● POP3

● RabbitMQ

● Salesforce

● Servlet

● JMS & ActiveMQ● SQL● SSH

● Validation - XML validation

● Websocket

● XMPP

● Activiti BPMN● Smooks

Vocabulary: Exchange

● Exchange = Wrapper object● encapsulates Messages (IN and

OUT) and Metadata

● Java interface used to implement message consumers or Message Translator EIP

● you can create a Component from a Processor

Camel Processor

Remember

Processing files with Apache Camel

Content Based Router EIP

Route messages to destination based on message contents

Content Based Router - Spring DSL

Normalizer EIP

Camel ETL - sample● read files from src/data/ directory● convert content to PersonDocument class using TypeConvertor system

(JAXB)● persist to DB using JPA component using TypeConvertor

● read from DB with JPA component as entity class● convert entity to XML file with JAXB and File component

Transactional Client EIP

Make client session with messaging system transactional● uses Spring transactions ● Transactional endpoints: JMS, ActiveMQ, AMPQ, JPA

Camel also supports Transactional Routes

Transactional Client

Load Balancer Pattern

● delegate processing based on load balancing policies

● out-of-the-box-policies:○ Round robin○ Random○ Sticky○ Topic○ Failover○ Weighted Round-robin○ Weighted random○ Custom

Load Balancer

Error Handling

Two distinct types:● transactional● non-transactional

Can configure policies like:● message redelivery● dead-letter queue

Error Handling - Try - Catch

Error Handling - Dead Letter Queue

● exceptions caught by Dead Letter Channel - which decides either:○ to redeliver○ or send to dead letted queue

Camel BAM

● business activity monitoring framework● monitor business processes across multiple exchanges● works across different endpoints

For every purchase order created by A, B generates an invoice.

Flight Mash-up revisited

Tooling: Fuse IDE

● Eclipse based RedHat JBoss product● build Camel routes graphically (Spring XML

DSL)● import existing XML routes● comes with pre-defined EIP building blocks● view local and remote ActiveMq brokers,

Camel end-points and routes● trace Camel routes at run-time

Fuse IDE - diagram view

Hawt.io - ultimate admin console

● lightweight html5 modular web-console● open-source (JBoss Cumunity project)● discovers what the JVM is running (JMX,

other) and exposes a web UI● lots of plugins:

○ ActiveMQ - default console for 5.9.x○ Camel - view/control routes○ OSGi - view/control bundles○ Karaf ○ JMX○ …..

Hawt.io - view routes

Hawt.io - ActiveMQ - browse/send

Hawt.io - monitor

Hawt.io - inspect JMX

Conclusions

● Camel is awesome tehnology● easy to get started● very powerfull● the comunity is great and helpful

Întrebări?