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

Enterprise Integration Patterns with Apache Camel

Nov 07, 2014

Download

Technology

Ioan Stan

Enterprise integration patterns, Apache Camel, EIP
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Enterprise Integration Patterns with Apache Camel

Enterprise Integration Patterns

withApache Camel

Ioan Eugen Stan20 Septembrie 2013

Axway Kickoff

Page 2: Enterprise Integration Patterns with Apache Camel

● 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

Page 3: Enterprise Integration Patterns with Apache Camel

Why do we need integration?

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

Page 4: Enterprise Integration Patterns with Apache Camel
Page 5: Enterprise Integration Patterns with Apache Camel

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

Page 6: Enterprise Integration Patterns with Apache Camel

The Book

● 65 design patterns● Formalized language● Covers:

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

Page 7: Enterprise Integration Patterns with Apache Camel

EIPs in detail (1)

Message

Pipes and Filters

Message translator

Message router

Messaging Systems

Page 8: Enterprise Integration Patterns with Apache Camel

EIPs in detail (2)

Point to Point channel

Publish Subscribe Channel

Dead letter queue

Guaranteed delivery

Messaging Channels

Page 9: Enterprise Integration Patterns with Apache Camel

EIPs in detail (3)

Event message

Request reply

Correlation identifier

Return Address

Messaging Construction

Page 10: Enterprise Integration Patterns with Apache Camel

EIPs in detail (4)

Content based router

Message filter

Dynamic router

Recipient list

Messaging Routing

Page 11: Enterprise Integration Patterns with Apache Camel

EIPs in detail (5)

Splitter

Aggregator

Resequencer

Routing slip

Messaging Routing

Page 12: Enterprise Integration Patterns with Apache Camel

EIPs in detail (6)

Content enricher

Content filter

Claim check

Normalizer

Messaging Transformation

Page 13: Enterprise Integration Patterns with Apache Camel

EIPs in detail (7)

Event driven consumer

Pooling consumer

Transactional client

Service activator

Messaging Endpoints

Page 14: Enterprise Integration Patterns with Apache Camel

EIPs in detail (8)

Control bus

Detour

Wire Tap

System Management

Page 15: Enterprise Integration Patterns with Apache Camel

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/

Page 16: Enterprise Integration Patterns with Apache Camel

Purchase example

Page 17: Enterprise Integration Patterns with Apache Camel

Normalization

Transform multiple message types into a common format

Page 18: Enterprise Integration Patterns with Apache Camel

Other examples

Page 19: Enterprise Integration Patterns with Apache Camel

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

Page 20: Enterprise Integration Patterns with Apache Camel

Camel Architecture

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

Page 21: Enterprise Integration Patterns with Apache Camel

Basics

● create a CamelContext● optionally configure components or

endpoints● add routing rules● start the context

Page 22: Enterprise Integration Patterns with Apache Camel

Example Java DSL

Page 23: Enterprise Integration Patterns with Apache Camel

Example Spring DSL

Page 24: Enterprise Integration Patterns with Apache Camel

Vocabulary: Component & Endpoint

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

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

Page 25: Enterprise Integration Patterns with Apache Camel

(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

Page 26: Enterprise Integration Patterns with Apache Camel

Vocabulary: Exchange

● Exchange = Wrapper object● encapsulates Messages (IN and

OUT) and Metadata

Page 27: Enterprise Integration Patterns with Apache Camel

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

● you can create a Component from a Processor

Camel Processor

Page 28: Enterprise Integration Patterns with Apache Camel

Remember

Processing files with Apache Camel

Page 29: Enterprise Integration Patterns with Apache Camel

Content Based Router EIP

Route messages to destination based on message contents

Page 30: Enterprise Integration Patterns with Apache Camel

Content Based Router - Spring DSL

Page 31: Enterprise Integration Patterns with Apache Camel

Normalizer EIP

Page 32: Enterprise Integration Patterns with Apache Camel

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

Page 33: Enterprise Integration Patterns with Apache Camel

Transactional Client EIP

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

Camel also supports Transactional Routes

Page 34: Enterprise Integration Patterns with Apache Camel

Transactional Client

Page 35: Enterprise Integration Patterns with Apache Camel

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

Page 36: Enterprise Integration Patterns with Apache Camel

Load Balancer

Page 37: Enterprise Integration Patterns with Apache Camel

Error Handling

Two distinct types:● transactional● non-transactional

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

Page 38: Enterprise Integration Patterns with Apache Camel

Error Handling - Try - Catch

Page 39: Enterprise Integration Patterns with Apache Camel

Error Handling - Dead Letter Queue

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

Page 40: Enterprise Integration Patterns with Apache Camel

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.

Page 41: Enterprise Integration Patterns with Apache Camel

Flight Mash-up revisited

Page 42: Enterprise Integration Patterns with Apache Camel

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

Page 43: Enterprise Integration Patterns with Apache Camel

Fuse IDE - diagram view

Page 44: Enterprise Integration Patterns with Apache Camel

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○ …..

Page 45: Enterprise Integration Patterns with Apache Camel

Hawt.io - view routes

Page 46: Enterprise Integration Patterns with Apache Camel

Hawt.io - ActiveMQ - browse/send

Page 47: Enterprise Integration Patterns with Apache Camel

Hawt.io - monitor

Page 48: Enterprise Integration Patterns with Apache Camel

Hawt.io - inspect JMX

Page 49: Enterprise Integration Patterns with Apache Camel

Conclusions

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

Page 50: Enterprise Integration Patterns with Apache Camel

Întrebări?