jdc2008 - enterprise integration and service oriented design

53
Enterprise Integration and Service-Oriented Design Hossam Karim

Post on 20-Oct-2014

2.749 views

Category:

Technology


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: JDC2008 - Enterprise Integration and Service Oriented Design

Enterprise Integration and Service-Oriented Design

Hossam Karim

Page 2: JDC2008 - Enterprise Integration and Service Oriented Design

Agenda The Enterprise Integration Problem Enterprise Integration Principles, Styles and

Messaging Concepts Service-Oriented Design Approach Frameworks and Implementations References Conclusion

Page 3: JDC2008 - Enterprise Integration and Service Oriented Design

The Enterprise Integration Problem

Enterprise integration requires a significant shift in corporate politics

Integration efforts typically have far-reaching implications on the business

The lack of widely implemented standards addressing core integration problems

The concept and technology learning curve

Page 4: JDC2008 - Enterprise Integration and Service Oriented Design

Enterprise Integration Principles

Integration is connecting computer systems, companies or people

Enterprise integration is the task of making disparate applications work together to produce a unified set of functionality

Page 5: JDC2008 - Enterprise Integration and Service Oriented Design

Integration Types

Information Portals Data Replication Shared Business Function Service-Oriented Architecture Distributed Business Process Business to Business Integration

Page 6: JDC2008 - Enterprise Integration and Service Oriented Design

Enterprise Integration TypesInformation Portals

Reso

urce

A

Reso

urce

B

Reso

urce

C

Basic data aggregation Single source of information

P o r t al

Page 7: JDC2008 - Enterprise Integration and Service Oriented Design

Enterprise Integration TypesData Replication

Data Store A

Data A

cces

s

Applic

ation

B

Data Store B

Data A

cces

s

Data moves on the database tier Consistency is dependent on the DBMS

implementation

Applic

ation

A

Page 8: JDC2008 - Enterprise Integration and Service Oriented Design

Enterprise Integration TypesShared Business Function

Applic

ation

A

Logic

A

Applic

ation

B

Logic

B

Shar

ed

Func

tion

Moves the control to the shared function logic Tightly couples all clients to the application

interfaces

Page 9: JDC2008 - Enterprise Integration and Service Oriented Design

Enterprise Integration TypesService-Oriented Architecture

Serv

ice

A Serv

ice

B Serv

ice

C Serv

ice

D

Applic

ation

Se

rvice

Applic

ation

Connects distributed applications and exposes services through a standard contract

Complex to design and implement

Page 10: JDC2008 - Enterprise Integration and Service Oriented Design

Enterprise Integration TypesDistributed Business Process

Busin

ess

Proc

ess

Func

tion A

Func

tion B

Func

tion C

Single point of invocation Requires other integration solutions to

function

Page 11: JDC2008 - Enterprise Integration and Service Oriented Design

Enterprise Integration TypesBusiness-To-Business Integration

Func

tion A

Func

tion B

Higher level of integration Still requires an integration solution

Page 12: JDC2008 - Enterprise Integration and Service Oriented Design

Enterprise Integration Styles

File Transfer Shared Database Remote Procedure Invocation Messaging

Page 13: JDC2008 - Enterprise Integration and Service Oriented Design

Enterprise Integration StylesFile Transfer

Applic

ation

A

Applic

ation

B

ExportImportSh

ared

Dat

a

Simplest form of integration Lacks timeliness and scalability

Page 14: JDC2008 - Enterprise Integration and Service Oriented Design

Enterprise Integration StylesShared Database

Appl

icat

ion

A

Data Store

Appl

icat

ion

B

Appl

icat

ion

C

Data A

cces

s

Data A

cces

s

Data A

cces

s

Promotes consistency Lacks portability and scalability

Page 15: JDC2008 - Enterprise Integration and Service Oriented Design

Enterprise Integration StylesRemote Procedure Invocation

Applic

ation

A

Applic

ation

B

StubSkeleton

Function Call

Reply

Provides more than data sharing Tightly couples integrated parties

Page 16: JDC2008 - Enterprise Integration and Service Oriented Design

Enterprise Integration StylesMessaging

Applic

ation

A

Applic

ation

A

Applic

ation

A

Event Layer

Message Bus

Transfer packets of data immediately, reliably, and asynchronously, using customizable formats.

Page 17: JDC2008 - Enterprise Integration and Service Oriented Design

Tightly Coupled Interfaces

APIA

APIC

APIB

DataA

Application A Application CApplication B

DataB

DataC

Requires minimum n(n-1)/2 interfaces, where n is the number of integrated applications

Page 18: JDC2008 - Enterprise Integration and Service Oriented Design

Loosely Coupled Interfaces

Requires exactly n interfaces, where n is the number of integrated applications

MessagingInterface A

MessagingInterface C

MessagingInterface B

DataA

Application A Application CApplication B

DataB

DataC

Messaging Bus

Page 19: JDC2008 - Enterprise Integration and Service Oriented Design

Enterprise Integration Using Messaging

Construction Channels Endpoints Routing Transformation Management Messaging Models Transactions

Page 20: JDC2008 - Enterprise Integration and Service Oriented Design

Message Construction

A message is a formatted unit of data A message consists of a header, properties and a body A sender marshals the data to construct the message A receiver un-marshals the data into its own data model

Message ReceiverSender

Page 21: JDC2008 - Enterprise Integration and Service Oriented Design

Message ConstructionExample: Spring Integration

Message

++++

getId ()getHeader ()getPayload ()isExpired ()

: Object: MessageHeader: T: boolean

<T>

Correlation ID

Pure Java object as a message body

Simplest form of a modeled message Uses generics to specialize message body type No marshaling or un-marshaling needed

Generic message body type

Header support

Page 22: JDC2008 - Enterprise Integration and Service Oriented Design

Message ConstructionExample: Java Business Integration

NormalizedMessage

+++++++++++

addAttachment (String id, DataHandler content)getContent ()getAttachment (String id)getAttachmentNames ()removeAttachment (String id)setContent (Source content)setProperty (String name, Object value)setSecuritySubject (Subject subject)getPropertyNames ()getProperty (String name)getSecuritySubject ()

: void: Source: DataHandler: Set: void: void: void: void: Set: Object: Subject

XML bodyAttachments support

Merged Properties andHeader supportSecurity support

Body is XML based Supports attachments and security subject

Page 23: JDC2008 - Enterprise Integration and Service Oriented Design

Message ConstructionExample: Apache Camel

Message

+++++++++++++++

getMessageId ()setMessageId (String messageId)getExchange ()getHeader (String name)getHeader (String name, Class<T> type)setHeader (String name, Object value)removeHeader (String name)getHeaders ()setHeaders (Map<String, Object> headers)getBody ()getBody (Class<T> type)setBody (Object body)setBody (Object body, Class<T> type)copy ()copyFrom (Message message)

: String: void: Exchange: Object: T: void: Object: Map<String, Object>: void: Object: T: void: void: Message: void

Correlation ID

What is this?

Pure POJO body

Header support

Page 24: JDC2008 - Enterprise Integration and Service Oriented Design

Message ConstructionMessage Exchange Patterns

<<Enum>>

ExchangePattern

++++++++...

InOnlyRobustInOnlyInOutInOptionalOutOutOnlyRobustOutOnlyOutInOutOptionalIn...

: EnumConstant: EnumConstant: EnumConstant: EnumConstant: EnumConstant: EnumConstant: EnumConstant: EnumConstant...

+++++- <<staticInitializer>>

getWsdlUri ()isInCapable ()isOutCapable ()isFaultCapable ()fromWsdlUri (String wsdlUri)_STATIC_INITIALIZER ()...

: String: boolean: boolean: boolean: ExchangePattern: void

Exchange Patterns

WSDL 2.0 based message exchange patterns

Page 25: JDC2008 - Enterprise Integration and Service Oriented Design

Exchange

++++++++++++++...

getPattern ()getProperty (String name)getProperty (String name, Class<T> type)removeProperty (String name)getProperties ()getIn ()getOut ()getOut (boolean lazyCreate)getFault ()getFault (boolean lazyCreate)isFailed ()copy ()copyFrom (Exchange source)getExchangeId ()...

: ExchangePattern: Object: T: Object: Map<String, Object>: Message: Message: Message: Message: Message: boolean: Exchange: void: String...

Message ConstructionMessage Exchange

Messages are encapsulated into a message exchange The pattern identifies what is encapsulated

Actual Message

This exchange pattern

Page 26: JDC2008 - Enterprise Integration and Service Oriented Design

Messaging Channels

A channel is a gateway for transmitting messages from a sender to a receiver

Sender and receiver do not know about each other Can be referred to as a pipe

SenderApplication

ReceiverApplication

MessageChannel

Page 27: JDC2008 - Enterprise Integration and Service Oriented Design

Message ChannelExample: Spring Integration

MessageChannel

+ DEFAULT_CAPACITY : int = 100

+++++++++

getName ()setName (String name)getDispatcherPolicy ()send (Message message)send (Message message, long timeout)receive ()receive (long timeout)clear ()purge (MessageSelector selector)

: String: void: DispatcherPolicy: boolean: boolean: Message: Message: List<Message<?>>: List<Message<?>>

Pure POJO model

Page 28: JDC2008 - Enterprise Integration and Service Oriented Design

Message ChannelExample: Java Business Integration

DeliveryChannel

++++++++++

close ()createExchangeFactory ()createExchangeFactory (QName interfaceName)createExchangeFactoryForService (QName serviceName)createExchangeFactory (ServiceEndpoint endpoint)accept ()accept (long timeout)send (MessageExchange exchange)sendSync (MessageExchange exchange)sendSync (MessageExchange exchange, long timeout)

: void: MessageExchangeFactory: MessageExchangeFactory: MessageExchangeFactory: MessageExchangeFactory: MessageExchange: MessageExchange: void: boolean: boolean

Factory method pattern, creates message exchange factories

Supports synchronous and asynchronous exchanges

Page 29: JDC2008 - Enterprise Integration and Service Oriented Design

Messaging Endpoints

An endpoint is a client of a messaging application that is capable of sending and receiving messages

The Message Endpoint encapsulates the messaging system from the rest of the application and customizes a general messaging API for a specific application and task

Data DataEndpoint EndpointChannelMessage

SenderApplication

ReceiverApplication

Page 30: JDC2008 - Enterprise Integration and Service Oriented Design

Message EndpointExample: Spring Integration

MessageHandler(handler)

+ handle (Message<?> message) : Message<?>

MessageEndpoint

+++

getName ()getSubscription ()getConcurrencyPolicy ()

: String: Subscription: ConcurrencyPolicy

<<AnnotationType>>

MessageEndpoint

+++

inputdefaultOutputpollPeriod

: String: String: int

= "" = "" = 0

<<AnnotationType>>

Handler

Page 31: JDC2008 - Enterprise Integration and Service Oriented Design

Message EndpointExample: Spring Integration

Page 32: JDC2008 - Enterprise Integration and Service Oriented Design

Message Processing Problem

DataEndpointChannel

ReceiverApplication

(n) messages

Exhausted at (n - x) messages

Exhausted at (n - y) messages

Client sends (n) messages Channel’s capacity is (n-x) messages Receiver application exhausted at (n-y) messages

Page 33: JDC2008 - Enterprise Integration and Service Oriented Design

Message Processing ProblemSEDA: Staged Event-Driven Architecture

Event Handler

Thread Pool

Event Queue

Controller

SEDA Stage

The Event Queue accepts incoming events

The Event Handler handles incoming events

The Thread Pool provides threading capabilities to the event handler

The Controller adjusts resources allocation and scheduling dynamically

Page 34: JDC2008 - Enterprise Integration and Service Oriented Design

Message Processing ProblemSEDA: Staged Event-Driven Architecture

IncomingMessages

ReceiverStage

Stage A

Stage B

Stage C

OutgoingMessages

OutgoingMessages

OutgoingMessages

Page 35: JDC2008 - Enterprise Integration and Service Oriented Design

Message Routing

A Message Router consumes a Message from one Message Channel and republishes it to a different Message Channel, depending on a set of conditions

Message InputChannel Message

Router

OutputChannel

A

OutputChannel

B

ReceiverA

ReceiverB

Page 36: JDC2008 - Enterprise Integration and Service Oriented Design

Message RouterExample: Spring Integration

Page 37: JDC2008 - Enterprise Integration and Service Oriented Design

Message Transformation

A Message Translator is a filter that translates one data format to another

IncomingMessage

TranslatedMessage

Translator

Page 38: JDC2008 - Enterprise Integration and Service Oriented Design

Message FlowExample: The VETRO Pattern

Valid

ate

Route

Opera

te

Transf

orm

Enric

h

Message 1 2 3 4 Message 5

All numbers and kinds of filters can be applied to a message before processing

Page 39: JDC2008 - Enterprise Integration and Service Oriented Design

System Management

The Control Bus uses the same messaging mechanism used by the application data but uses separate channels to transmit data that is relevant to the management of components involved in the message flow

Processor A

Processor B

Processor C

Message Flow

Control Bus

Configuration

Heartbeat

Test Messages

Exceptions

Statistics

Live Console

Message X Message X’

Page 40: JDC2008 - Enterprise Integration and Service Oriented Design

Messaging Models

Producer(Publisher)

Topic

Consumer

Consumer

Consumer

Each subscriber (zero or more)Gets a copy

Publish and subscribe ( 1 → Many)

Producer(Queue Sender)

Queue

Consumer

Consumer

Consumer

Potential Receivers (zero or one)

Point-to-Point ( 1 → 1)

Publish/Subscribe Model Point-to-Point Model

Page 41: JDC2008 - Enterprise Integration and Service Oriented Design

Store and Forward Messaging

Guaranteed once and only once message delivery Transparent to the messaging clients

Producer 1. sendTopic

Queue

Data Store

2. store

Consumer3. forward

Page 42: JDC2008 - Enterprise Integration and Service Oriented Design

Transactional MessagingLocal Transactions

Producer ConsumerMessaging

Server

1. send

2. send

3. commit

4. receive

5. receive

6. commit

Producer sends one or more messages in a transactional context Producer commits the transaction Consumer receives all messages Consumer commits the transaction

Page 43: JDC2008 - Enterprise Integration and Service Oriented Design

Transactional MessagingDistributed Transactions

Producer sends one or more messages in the transaction manager context

Producer updates another resource Producer commits the transaction

ProducerMessaging

Server

1. send

Data Store

2. Update

3. Commit, Rollback or Recover

XA Transaction Manager

Page 44: JDC2008 - Enterprise Integration and Service Oriented Design

Messaging Protocol Stack

TCP/IP

HTTP/S

TCP/IP TCP/IP TCP/IP

HTTP/S HTTP/S

TCP/IP

SSL

JMS

XML

MessagingBus

MessagePayload

JMSJMS

SOAP

MessagingBus

MessagePayload

XML

MessagingBus

MessagePayload

SOAP

MessagingBus

MessagePayload

MessagingBus

MessagePayload

NetworkingProtocol

TransportProtocol

MessagingProtocol

PayloadProtocol

Clients expect simple and widely used protocols Legacy applications communicate in proprietary protocols Firewalls require tunneling through opened ports

Page 45: JDC2008 - Enterprise Integration and Service Oriented Design

Service Meta-Model

1..*operations

0..*infault

0..*outfault

1..1pattern

0..*input

0..*output

1..1message

1..*endpoints

1..1binding

Interface

+ name : String

Binding

++

nametype

: String: URI

Service

+ name : String

Endpoint

++

nameaddress

: String: URI

Operation

+ name : String

Fault

Message

+ label : String

<<enumeration>>

MessageExchangePattern

+ name : String

Page 46: JDC2008 - Enterprise Integration and Service Oriented Design

Service Component Model

ServiceComponent

<<delegate>><<delegate>>

ServiceImplementation

+ <<InOut>> businessOperation (Message input) : Message

http-endpoint jms-endpoint

<<remote>>BusinessInterface : 1

<<remote>>BusinessInterface : 2

Exposed Interface

Protocol SpecificEndpoint

ServiceImplementation

EncapsulatingComponent

Page 47: JDC2008 - Enterprise Integration and Service Oriented Design

Service Component Clients

ServiceComponent

<<delegate>><<delegate>>

ServiceImplementation

+ <<InOut>> businessOperation (Message input) : Message

http-endpoint jms-endpoint

<<remote>>BusinessInterface : 1

<<remote>>BusinessInterface : 2

<<client>>HttpClient

http

<<client>>JmsClient

jms

Interface Binding

Protocol Dependent

Client

Page 48: JDC2008 - Enterprise Integration and Service Oriented Design

Service-Oriented Design Approach

Message Bus

Service-OrientedEnvironment

Com

ponent

Service Endpoints

Service Transport ProtocolSupport

ServiceContract

Messaging BusEndpoint

NormalizedMessages

Page 49: JDC2008 - Enterprise Integration and Service Oriented Design

Service-Oriented Design Approach Example: Java Business Integration

JBI Runtime Environment

Service Unit

Service Assembly

Service Unit Service Unit

Jbi.xml Jbi.xml Jbi.xml

Jbi.xml

Jbi.xml

Component Shared Library

Service Engine

Binding Component

Jbi.xml

Normalized Message Router

Install

Deploy

Message Bus

ActivateEndpoints

CommonLogic

ExposeServices

Page 50: JDC2008 - Enterprise Integration and Service Oriented Design

Service-Oriented Design Approach Example: Java Business Integration

Serv

ice

Engin

e

Directory Server

Relational Database

XML Native Database

Bindin

g

Com

ponent

Service Instances Services are exposed on arbitrary

supported protocols Messages are normalized and

delivered to their channels Messages are routed through the

normalized message router to the target service engine

The service engine performs its task and replies to the component if appropriate

Page 51: JDC2008 - Enterprise Integration and Service Oriented Design

Frameworks and Implementations Spring Integration

http://www.springframework.org/spring-integration/ Apache ServiceMix

http://servicemix.apache.org/ Apache Camel

http://activemq.apache.org/camel/ Sun OpenESB

https://open-esb.dev.java.net/ Mule

http://mule.mulesource.org/

Page 52: JDC2008 - Enterprise Integration and Service Oriented Design

References Enterprise Integration Patterns: Designing, Building, and

Deploying Messaging Solutions - Gregor Hohpe, Bobby Woolf

Enterprise Service Bus – Dave Chappell SOA: Principles of Service Design - Thomas Erl SEDA: An Architecture for Well Conditioned, Scalable

Internet Services - Matt Welsh, David Culler, and Eric Brewer Java™ Business Integration (JBI) 1.0 – JSR 208 Specification -

Ron Ten-Hove, Peter Walker

Thanks to Dave Chappell for granting permission to use his diagramming notation in this presentation

Page 53: JDC2008 - Enterprise Integration and Service Oriented Design

Conclusion Don’t reinvent the wheel Keep close to the standards Spend time understanding and evaluating your

infrastructure Not all frameworks and design solutions are suitable for

each environment Design to scale, but don’t over design Explore integration solutions and frameworks Practice service-oriented design and implementation