style integration front-end to java · pdf filemule as an esb-style integration front-end to...

75
mule as an esb-style integration mule as an esb-style integration front-end to java ee applications gerald loeffler, phd mba senior architect/developer objectlab financial ltd objectlab financial ltd available from www.gerald-loeffler.net/download/mule_ejug_2007-06-25.pdf

Upload: vudien

Post on 31-Mar-2018

223 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

mule as an esb-style integration

mule as an esb-style integration

front-end to java eeapplications

gerald

loeffler, phd m

ba

senior architect/developer

objectlabfinancial ltd

objectlabfinancial ltd

available from www.gerald-loeffler.net/download/m

ule_ejug_2007-06-25.pdf

Page 2: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

ObjectLab Financial Ltd

2

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 3: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

references and resources

•[1] mule resources

3

▫web site/wiki/guides http://w

ww.m

ulesource.org

▫mailing list

▫examples (!)

▫source code (!)

•[2] "enterprise integration patterns", gregorhohpeet al.

▫http://w

ww.eaipatterns.com/

•[3] "Combining Service-Orien

ted Architecture and Even

t-Driven

Architecture using an Enterprise Service Bus", jean-

louismarechaux, ibm

mule and integrating java eeapplications | gerald

loeffler

| ejuglondon| june2007

Page 4: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

esb

–pattern or product?

•"A

n Enterprise Service Bus is an architectural patternand 4

can be im

plemen

ted by m

any different productswithin the

organization, and assem

bled together to act as a federated

bus. M

ore and m

ore ven

dors are now offering a complete

productto fulfill enterprise integrationneeds." [3]

•"combines event-driven

and service orientedapproaches to

simplify integration of business units, bridging

heterogen

eous platform

s and environmen

ts. The ESB acts

heterogen

eous platform

s and environmen

ts. The ESB acts

as an interm

ediary layer to enable communicationbetween

different application processes." [3]

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 5: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

esb

–pattern or product?

•"facilitates and sim

plifies business integration through

5

transport, event and mediation services. It connects and

mediates all communications and interactions between

heterogen

eous nodes, both in a Service-Orien

ted

Architecture (synchronous one-to-one approach) and an

Even

t-Driven

Architecture (asynchronous many-to-m

any

approach)." [3]

•esbcharacteristics/features:

•esbcharacteristics/features:

▫supports synchronous and asynchronous interaction

▫message routing and transform

ation

▫transport m

ediation

▫distributed/fed

erated?

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 6: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

mule 1/2

•even

t-based open

-source esb

6

▫even

t ≈ m

essage

•mature, proprietary (neither jbi nor sca)

•active community

•integrates nicely with spring

•supports many transports/protocols

▫ejbinvocation (jrmp, iiop), email (sm

tp, pop3, im

ap), file, ftp,

▫ejbinvocation (jrmp, iiop), email (sm

tp, pop3, im

ap), file, ftp,

http/https, jdbc, jms, ipmulticast, tcp/ipand ssl, udp,

soap/w

sdl(via axis1, xfire, glue), xmpp, internal in-m

emory

("vm") [1]

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 7: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

mule 2/2

•deploymen

t stand-alone or in app server (also as rar)

7

•framew

ork for and implemen

tations of

▫transform

ers

▫routers

▫splitters/aggregators

•transaction dem

arcation (local and xa, pluggable)

•thread, queu

e and pool managem

ent

•thread, queu

e and pool managem

ent

•curren

tly 1.4.1

▫2.0 (july 2007) will be more tightly integrated with Spring 2.x

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 8: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

8

book reviews, java eewith rem

ote ejbs, file upload, webservice, feed

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 9: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

the integration scenario

•"our" application ("A

") deals in book reviews

9

▫domain objects Book, Person, Review

•deployed in java eeapplication server, accessed by java

clients through rem

ote slsbs

•need to integrate with publishing house Zsolnay("Z") to

exchange reviews

▫step 1: they will initially sen

d us reviews in flat files

▫step 2: they intend to m

ove to web services real soon now

▫step 3: will ultim

ately also accept reviews from our system

•we expect many m

ore integrations along these lines

•make our system

/application integration ready/frien

dly

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 10: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

application domain m

odel

10

Book

Person

id firstN

ame

lastName

authors

Review

id

critic

1

11..*

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Book

id isbn

title

id rating

text

subject

1

Page 11: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

application services

11

ReviewService

PersonService

List<Person> getPersonsB

yName(String firstName, String lastName)

ReviewService

List<Review> getReviewsB

yBook(String isbn)

void addReview(R

eview new

Review)

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

BookService

Book getBookByIsbn(String isbn)

Page 12: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

application layers

12

service

ReviewService, ...

ejb

ReviewSLSBean, ...

java client

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

domain

Book, Person, Review

repository

ReviewRepository, ...

hibernate

ReviewService, ...

Page 13: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

far en

vironmen

t

a systems map of this integration scenario

13

far en

vironmen

t

near en

vironmen

t

AZ

others

others

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

others

Page 14: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

criteria for assessing integration solutions

•correctness

14

•elegance

•developmen

t/maintenance/operation effort (i.e., €£$)

•resilien

ce to infrastructure outages

•runtime perform

ance

•extent of coupling ...

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 15: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

different form

s of coupling

•(degree of) coupling := the extent of (implicit or explicit)

15

assumptions between communication partners

▫no communication without assumptions!

▫looser coupling results in

�increased resilience to changeof a communication partner

�broken

communication going undetected

•in tim

e (absolute and difference)

▫partner has to be available now

and every 5 seconds

▫partner has to be available now

and every 5 seconds

•in control flow

▫A passes control to Z, and blocks until Z passes control back

•in data/w

ire form

ats

▫en

dian-ness, iiop, varcharfield len

gth

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 16: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

different form

s of coupling

•in programming language

16

▫java/jvm, is json really javascript?

•in exchange of structural meta-data

▫java classes/files, client-side stubs, xml-schem

ata, d

tds

•in reliance on shared state

▫session/conversation, shared database and keys (!)

•in sem

antics of data or communication

•in sem

antics of data or communication

▫querying for the spouse of a m

an returns a woman

▫the last 6 digits of the ssnconsist of the date of birth

▫returning null from a query signals illegal input, returning an

empty list means no results

▫first invoke service S1 before invoking any other service

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 17: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

does use of xml/wslead to loose coupling?

•it m

ay -but consider that these honourable techniques

17

increase coupling:

▫validation against a common schem

a, possibly versioned

▫compile-time binding to java artefacts (jax-w

s, jaxb, ...)

▫use of "deep" xpath

expressions

▫request-response interactions

▫reliance on ws-rm

, ws-security (incl. ciphers)

▫inference of dateTim

etime zones

▫inference of dateTim

etime zones

▫sharing data m

odels: ubl, ...

▫making assumptions about semantically under-defined aspects

of the service data m

odel

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 18: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

a "static fanatic"'s use of xml payloads

•cherish xml as human-readable/editable and language-

18

agnostic –

the xml payload is a primary artifact

•paranoid of misinterpretations of xml payloads that are

detected late (at runtime rather than compile-time) or not

at all

•prefer strict xml-schem

a over lax xml-schem

a over dtd over

no schem

a

▫always validate each m

essage at least once against its schem

a

•always try to use static (compile-time) xml-java binding

(jaxb) and operate on xml documen

ts either through their

bound java objects or through xslt/xpath

▫but always fine-tune xml-schem

a m

aking full use of its features

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 19: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

19

Z reviews csv, direct ejb, mdb, monolithic esb, distributed esb

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 20: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

the Z reviews csv file form

at

20

reviewer

book id

mark

review

First1 Last1

Z1

1Best ever!

First3 Last3

Z2

5Sim

ply Terrible

Z1

2Good by nobody

Un Known

Z3

2Quite OK

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Un Known

Z3

2Quite OK

First2 Last2

Zx

1Good!

Page 21: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

solution 1: remote ejb

call

21

solution 1: direct ejb

call

21

ZIntegration

SLSBean

Z reviews

csv

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 22: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

solution 1: characteristics

•need to change application to add IntegrationSLSBean

22

•iiopor jrmpnot firewall-frien

dly

▫need http tunnelling or similar

•Zsolnayand our system

are tightly coupled in alm

ost every

respect, in particular:

▫change to file form

at => change/redeploymen

t of our app

▫need to ship clien

t jar and app server clien

t jars to Z

▫synchronous call

�risk txand/or protocol timeout with large files

•strongly affected by infrastructure outages

•easy to develop and test

•deterministic perform

ance characteristics

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 23: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

solution 2: mdb-based implementation

23

ZIntegration

MDBean

Z reviews

csv

jms

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 24: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

solution 2 compared to solution 1

•no need to ship clien

t jar to Z (but app server clien

t jars)

24

•asynchronous delivery and processing

▫no risk of protocol timeout on large files

▫still risk of tx

timeout if m

db processes in one tx

(cmt)

•still strongly affected by infrastructure outages!

▫jndilookups and m

essage send are still synchronous remote

calls; jndi-bound objects may not survive app server restart

•harder to test

•risk of incorrectness introduced?

▫messages m

ay be re-ordered

by jmsif not sent within one jm

ssession; may be proessed concurren

tly by m

db instances

•less deterministic perform

ance

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 25: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

solution 3: monolithic esb

25

Zservice

SLSBeans

Z reviews

csv

mule

file

sys

Review

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 26: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

solution 3: monolithic esb

in m

ore detail

26

file

sys

z_filedrop

f2s

splitter

Z reviews

csvfile

transform

er

LineSplitter

Z reviews

csv

Z review

csv

Z review

csv

Z review

csv Transformer

Mapping

SLSBean

Person

SLSBean

Book

SLSBean

mule

Review

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Review

SLSBean

Splitter

...Transformer

SLSBean

Page 27: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

mule xml configuration file

<mule

mule

mule

mule- ---configuration

configuration

configuration

configuration>

27

<environment-properties />

<mule-environment-properties />

<container-context />

<connector />

<transformers />

<global-endpoints />

<interceptor-stack />

<model>

<exception-strategy />

<mule-descriptor />

</model>

</mule

/mule

/mule

/mule- ---configuration

configuration

configuration

configuration>

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 28: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

environment properties

<environment

environment

environment

environment- ---properties

properties

properties

properties>

<property name="to_submit_dir" value="to_submit" />

28

<property name="to_submit_dir" value="to_submit" />

<property name="submitted_dir" value="submitted" />

<property name="jndi_initial_factory"

value="org.jnp.interfaces.NamingContextFactory" />

<property name="jndi_provider_url" value="jnp://localhost:1099" />

</environment

/environment

/environment

/environment- ---properties

properties

properties

properties>

•referenced with ${name}

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

▫in all valueandaddressattributes

Page 29: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

mule client-mode &

connection strategy

<mule

mule

mule

mule- ---environment

environment

environment

environment- ---properties

properties

properties

propertiesclientMode="true">

<connection

connection

connection

connection- ---strategy

strategy

strategy

strategy

29

<connection

connection

connection

connection- ---strategy

strategy

strategy

strategy

className="org.mule.providers.SimpleRetryConnectionStrategy">

<properties>

<property name="retryCount" value="3600" />

<property name="frequency" value="1000" />

</properties>

</connection

/connection

/connection

/connection- ---strategy

strategy

strategy

strategy>

</mule

/mule

/mule

/mule- ---environment

environment

environment

environment- ---properties

properties

properties

properties>

•en

able clien

t-mode unless server-m

ode is needed

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

•en

able clien

t-mode unless server-m

ode is needed

▫the MuleClientremote dispatcher needs server-m

ode

•connection strategy deals with exceptions in connectors

▫highly recommen

ded

when

rem

ote calls are involved

Page 30: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

container context and spring integration

<container

container

container

container- ---context

context

context

context

className='org.mule.extras.spring.SpringContainerContext

SpringContainerContext

SpringContainerContext

SpringContainerContext'>

30

className='org.mule.extras.spring.SpringContainerContext

SpringContainerContext

SpringContainerContext

SpringContainerContext'>

<properties>

<property name="configFile"

value="springContext-monolith.xml" />

</properties>

</container

/container

/container

/container- ---context

context

context

context>

•mule containers are external componen

t & object factories

▫object/beans referenced with implementationattribute

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

▫object/beans referenced with implementationattribute

•other container context im

plemen

tations

▫jnditree, session ejbs, pico, plexus, hivem

ind[1]

•mule can also be configured and launched entirely from a

spring context (w

ithout a m

ule configxml)!

Page 31: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

file connector

<connector

connector

connector

connectorname="file_connector"

className="org.mule.providers.file.FileConnector

FileConnector

FileConnector

FileConnector">

31

className="org.mule.providers.file.FileConnector

FileConnector

FileConnector

FileConnector">

<properties>

<property name="moveToDirectory" value="${submitted_dir}" />

<property name="moveToPattern"

value="${ORIGINALNAME}.${DATE:yyyy-MM-dd_HH-mm-ss-SSS}" />

<property name="binary" value="false" />

<property name="autoDelete" value="false" />

</properties>

</connector

/connector

/connector

/connector>

</connector

/connector

/connector

/connector>

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

•im

possible (?) to configure it to not move/delete files when

outbound communication fails

▫make outbound communication impossible to fail

Page 32: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

ejb

(slsb) connector

<connector

connector

connector

connectorname="ejb_connector"

className="org.mule.providers.ejb.EjbConnector

EjbConnector

EjbConnector

EjbConnector">

32

className="org.mule.providers.ejb.EjbConnector

EjbConnector

EjbConnector

EjbConnector">

<properties>

<property name="jndiInitialFactory"

value="${jndi_initial_factory}" />

<property name="jndiProviderUrl" value="${jndi_provider_url}" />

<property name="securityPolicy" value="security.policy" />

</properties>

</connector

connector

connector

connector>

•for calling slsbmethod through m

ule endpoints

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

•for calling slsbmethod through m

ule endpoints

▫from outbound or nested routers (but prefer spring to latter)

•ejbcontainer context is an "early binding" alternative

•undocumen

ted lookup/caching beh

aviour fails on reconnect

▫prefer spring jee:remote-slsbwhen

ever possible

Page 33: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

jmsconnector

<connector

connector

connector

connectorname="jms_connector"

className="org.mule.providers.jms.JmsConnector

JmsConnector

JmsConnector

JmsConnector">

33

className="org.mule.providers.jms.JmsConnector

JmsConnector

JmsConnector

JmsConnector">

<properties>

<property name="jndiInitialFactory"

value="${jndi_initial_factory}" />

<property name="jndiProviderUrl" value="${jndi_provider_url}" />

<property name="connectionFactoryJndiName"

value="ConnectionFactory" />

<property name="jndiDestinations" value="true" />

<property name="forceJndiDestinations" value="true" />

<property name="forceJndiDestinations" value="true" />

<property name="persistentDelivery" value="true" />

<property name="specification" value="1.1" />

<property name="maxRedelivery" value="5" />

</properties>

</connector

/connector

/connector

/connector>

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 34: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

transform

ers

<transformers

transformers

transformers

transformers>

<transformer name="f2s"

34

<transformer name="f2s"

className="org.mule.providers.file.transformers.FileToString" />

<transformer name="o2jms" className=

"org.mule.providers.jms.transformers.ObjectToJMSMessage" />

</transformers

/transformers

/transformers

/transformers>

•infrastructural, technical transform

ers provided by m

ule

•more business-related transform

ers written

in projects

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

•more business-related transform

ers written

in projects

▫extend org.mule.transformers.AbstractTransformer

▫not a spring bean if configured via m

ule xml

�simple transform

ation => transform

er, complex => componen

t

▫see later for example

Page 35: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

endpoints

<global

global

global

global- ---endpoints

endpoints

endpoints

endpoints>

<endpoint name="to_submit_dir" address="file://${to_submit_dir}" 35

<endpoint name="to_submit_dir" address="file://${to_submit_dir}"

connector="file_connector" transformers="f2s" />

<endpoint name="z_reviews_csv" address="vm://z_reviews_csv" />

<endpoint name="review"

address="ejb:/ReviewSLSBean?method=addReview"

connector="ejb_connector" remoteSync="true" />

<endpoint name="invalid_msg"

address="jms://queue/INT.INVALID_MESSAGE"

connector="jms_connector" transformers="o2jms" />

connector="jms_connector" transformers="o2jms" />

</global

/global

/global

/global- ---endpoints

endpoints

endpoints

endpoints>

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

•central veh

icle for mules protocol/transport abstraction

•best defined as global en

dpoints

•only define fixed transform

ers => can amen

d at use tim

e

Page 36: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

interceptors

<interceptor

interceptor

interceptor

interceptor- ---stack

stack

stack

stackname="default">

<interceptor className="util.esb.mule.LoggingInterceptor" />

36

<interceptor className="util.esb.mule.LoggingInterceptor" />

</interceptor

/interceptor

/interceptor

/interceptor- ---stack

stack

stack

stack>

•cf. aoparound advice

public class LoggingInterceptorextends EnvelopeInterceptor{

@Override public void before(Invocation i) {...}

@Override public void after(Invocation i) {...}

} mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

•cf. aoparound advice

•applies to componen

t invocations

▫not invoked

for BridgeComponent

�use PassThroughComponentinstead

•for debugging, but also for message store/history/audit [2]

Page 37: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

component exception strategy

<exception

exception

exception

exception- ---strategy

strategy

strategy

strategy

className="util.esb.mule.ExceptionAwareExceptionStrategy

ExceptionAwareExceptionStrategy

ExceptionAwareExceptionStrategy

ExceptionAwareExceptionStrategy">

37

className="util.esb.mule.ExceptionAwareExceptionStrategy

ExceptionAwareExceptionStrategy

ExceptionAwareExceptionStrategy

ExceptionAwareExceptionStrategy">

<global-endpoint name="invalid_msg" />

<global-endpoint name="manual_intervention" />

</exception

exception

exception

exception- ---strategy

strategy

strategy

strategy>

public class ExceptionAwareExceptionStrategy

ExceptionAwareExceptionStrategy

ExceptionAwareExceptionStrategy

ExceptionAwareExceptionStrategyimplements

ExceptionListener{

public void exceptionThrown(Exception e) {...}

} mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

•handles exceptions thrown by componen

ts

▫usually business exceptions, i.e. project-depen

den

t

▫a special form

of synchronous content-based routing for

exceptions

Page 38: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

read file, pass on as string payload

<mule

mule

mule

mule- ---descriptor

descriptor

descriptor

descriptorname="z_filedrop"

implementation="org.mule.components.simple.PassThroughComponent

PassThroughComponent

PassThroughComponent

PassThroughComponent">38

implementation="org.mule.components.simple.PassThroughComponent

PassThroughComponent

PassThroughComponent

PassThroughComponent">

<inbound-router>

<global-endpoint name="to_submit_dir" />

</inbound-router>

<outbound-router>

<router className=

"org.mule.routing.outbound.OutboundPassThroughRouter">

<global-endpoint name="z_reviews_csv" />

</router>

</router>

</outbound-router>

<interceptor name="default" />

</mule

/mule

/mule

/mule- ---descriptor

descriptor

descriptor

descriptor>

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 39: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

split csv

payload into 1-line csv

messages

<mule

mule

mule

mule- ---descriptor

descriptor

descriptor

descriptorname="splitter" implementation=

"org.mule.components.simple.PassThroughComponent

PassThroughComponent

PassThroughComponent

PassThroughComponent">

39

"org.mule.components.simple.PassThroughComponent

PassThroughComponent

PassThroughComponent

PassThroughComponent">

<inbound-router>

<global-endpoint name="z_reviews_csv" />

</inbound-router>

<outbound-router>

<router className="util.esb.mule.LineSplitter

util.esb.mule.LineSplitter

util.esb.mule.LineSplitter

util.esb.mule.LineSplitter">

<global-endpoint name="z_review_csv" />

<properties>

<property name="preserveHeader" value="true" />

<property name="preserveHeader" value="true" />

</properties>

</router>

</outbound-router>

<interceptor name="default" />

</mule

/mule

/mule

/mule- ---descriptor

descriptor

descriptor

descriptor>

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 40: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

transform

csv

into Review, invoke ejb

<mule

mule

mule

mule- ---descriptor

descriptor

descriptor

descriptorname="transformer"

implementation="zReviewCsvToReviewTransformer

zReviewCsvToReviewTransformer

zReviewCsvToReviewTransformer

zReviewCsvToReviewTransformer">

40

implementation="zReviewCsvToReviewTransformer

zReviewCsvToReviewTransformer

zReviewCsvToReviewTransformer

zReviewCsvToReviewTransformer">

<inbound-router>

<global-endpoint name="z_review_csv" />

</inbound-router>

<outbound-router>

<router className=

"org.mule.routing.outbound.OutboundPassThroughRouter">

<global-endpoint name="review" />

</router>

</router>

</outbound-router>

<interceptor name="default" />

</mule

/mule

/mule

/mule- ---descriptor

descriptor

descriptor

descriptor>

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 41: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

springContext-monolith.xml

<bean

bean

bean

beanid="zReviewCsvToReviewTransformer

zReviewCsvToReviewTransformer

zReviewCsvToReviewTransformer

zReviewCsvToReviewTransformer" scope="prototype"

class="bookreview.integration.esb.ZReviewCsvToReviewTransformer

ZReviewCsvToReviewTransformer

ZReviewCsvToReviewTransformer

ZReviewCsvToReviewTransformer">41

class="bookreview.integration.esb.ZReviewCsvToReviewTransformer

ZReviewCsvToReviewTransformer

ZReviewCsvToReviewTransformer

ZReviewCsvToReviewTransformer">

<property name="mappingService" ref="mappingSLSB" />

<property name="personService" ref="personSLSB" />

<property name="bookService" ref="bookSLSB

bookSLSB

bookSLSB

bookSLSB" />

</bean

/bean

/bean

/bean>

<jee:remote

jee:remote

jee:remote

jee:remote- ---slsb

slsb

slsb

slsbid="bookSLSB

bookSLSB

bookSLSB

bookSLSB" jndi-name="BookSLSBean"

business-interface="bookreview.service.BookService"

home-interface="bookreview.ejb.BookSLSBHome"

lookup-home-on-startup="false" cache-home="true"

lookup-home-on-startup="false" cache-home="true"

refresh-home-on-connect-failure="true">

<jee:environment>

...

</jee:environment>

...

</ ///jee:remote

jee:remote

jee:remote

jee:remote- ---slsb

slsb

slsb

slsb>

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 42: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

a transform

ing component using spring di

public class ZReviewCsvToReviewTransformer

ZReviewCsvToReviewTransformer

ZReviewCsvToReviewTransformer

ZReviewCsvToReviewTransformer{

42

public void setMappingService(MappingServicemappingService) {

this.mappingService= mappingService;

} public void setPersonService(PersonServicepersonService) {

this.personService= personService;

} public void setBookService(BookServicebookService) {

this.bookService= bookService;

this.bookService= bookService;

} public Review transform(String csv)

throws InvalidMessageException, MappingException{...}

...

} mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 43: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

summary: monolithic esb

in detail

43

file

sys

z_filedrop

f2s

splitter

Z reviews

csvfile

transform

er

LineSplitter

Z reviews

csv

Z review

csv

Z review

csv

Z review

csv Transformer

Mapping

SLSBean

Person

SLSBean

Book

SLSBean

mule

Review

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Review

SLSBean

Splitter

...Transformer

SLSBean

Page 44: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

characteristics of the m

onolithic esb

•no need to change application once M

appingService added

44

▫acceptance and transform

ation of Z review csv

occurs in stand-

alone mule outside of application

▫mule calls several slsbsexposed by the application

�mule needs clien

t jar and app server clien

t jars

�many fine-grained synchronous remote ejb

calls!

▫each csv

line transform

ed and imported

separately

�ordering m

ay get lost

�ordering m

ay get lost

•Z now "just" needs to push csv

file to us

•iden

tified need for mapping service => see later

▫accessed as remote slsb

•a fragile, strongly coupled, very chatty solution

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 45: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

solution 4: distributed esb

45

Z

service

SLSBeans

Z reviews

csv

file

Review

amq

broker

mule

Z reviews

csv

jms

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

file

sys

amq

broker

mule

Page 46: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

store-and-forw

ard vs. client-server messaging46

process

process

process (app server)

msg broker

jms

message

consumer

jms

message

producer

destination

process

process

process (app server)

process

process

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

jms

message

producer

process

msg broker

destination

jms

message

consumer

process

msg broker

destination

Page 47: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

principles behind a fail-safe distributed esb

•assume that remote connections will fail

47

•let infrastructure cope with failed connections

▫store-and-forw

ard m

essaging architecture

•send locally, receive locally or remotely:

▫only sen

d to local (in-process) message broker

�never left stranded with a m

essage that can not be sent

▫prefer to receive from local message broker but can consume

from arbitrary rem

ote endpoints if required

from arbitrary rem

ote endpoints if required

�if connectivity fails then

message processing never even

starts

•synergistic deploymen

t of mule with embedded active m

qmessage broker (acting as jm

s provider)

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 48: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

Z-side m

ule xml config

<container

container

container

container- ---context

context

context

context

className='org.mule.extras.spring.SpringContainerContext

SpringContainerContext

SpringContainerContext

SpringContainerContext'>

48

className='org.mule.extras.spring.SpringContainerContext

SpringContainerContext

SpringContainerContext

SpringContainerContext'>

<properties>

<property name="configFile" value="springContext

springContext

springContext

springContext- ---distr1.xml

distr1.xml

distr1.xml

distr1.xml" />

</properties>

</container

/container

/container

/container- ---context

context

context

context>

<connector

connector

connector

connectorname="jms_connector"

className="org.mule.providers.jms.activemq.ActiveMqJmsConnector

ActiveMqJmsConnector

ActiveMqJmsConnector

ActiveMqJmsConnector">

<properties>

<property name="persistentDelivery" value="true" />

<property name="persistentDelivery" value="true" />

<property name="specification" value="1.1" />

<property name="maxRedelivery" value="5" />

<container-property name="connectionFactory"

reference="amqConnectionFactory

amqConnectionFactory

amqConnectionFactory

amqConnectionFactory" />

</properties>

</connector

/connector

/connector

/connector>

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 49: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

Z-side spring context & active m

q config

49

<bean

bean

bean

beanid="amqConnectionFactory

amqConnectionFactory

amqConnectionFactory

amqConnectionFactory"

class="org.apache.activemq.ActiveMQConnectionFactory

ActiveMQConnectionFactory

ActiveMQConnectionFactory

ActiveMQConnectionFactory">

<broker

broker

broker

brokerbrokerName="amq

amq

amq

amq- ---distr1

distr1

distr1

distr1" persistent="true" useJmx="false"

xmlns="http://activemq.org/config/1.0">

<transportConnectors

transportConnectors

transportConnectors

transportConnectors>

<transportConnector uri="tcp://localhost:55501

tcp://localhost:55501

tcp://localhost:55501

tcp://localhost:55501" />

</transportConnectors

/transportConnectors

/transportConnectors

/transportConnectors>

class="org.apache.activemq.ActiveMQConnectionFactory

ActiveMQConnectionFactory

ActiveMQConnectionFactory

ActiveMQConnectionFactory">

<constructor-arg

value="vm://localhost?brokerConfig=xbean:activemq

vm://localhost?brokerConfig=xbean:activemq

vm://localhost?brokerConfig=xbean:activemq

vm://localhost?brokerConfig=xbean:activemq- ---distr1.xml

distr1.xml

distr1.xml

distr1.xml" />

</bean

/bean

/bean

/bean>

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

</transportConnectors

/transportConnectors

/transportConnectors

/transportConnectors>

<networkConnectors

networkConnectors

networkConnectors

networkConnectors>

<networkConnector uri="static://(tcp://localhost:55502)

static://(tcp://localhost:55502)

static://(tcp://localhost:55502)

static://(tcp://localhost:55502)" />

</networkConnectors

/networkConnectors

/networkConnectors

/networkConnectors>

</broker

/broker

/broker

/broker>

Page 50: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

A-side m

ule xml config

<container

container

container

container- ---context

context

context

context

className='org.mule.extras.spring.SpringContainerContext

SpringContainerContext

SpringContainerContext

SpringContainerContext'>

50

className='org.mule.extras.spring.SpringContainerContext

SpringContainerContext

SpringContainerContext

SpringContainerContext'>

<properties>

<property name="configFile" value="springContext

springContext

springContext

springContext- ---distr2.xml

distr2.xml

distr2.xml

distr2.xml" />

</properties>

</container

/container

/container

/container- ---context

context

context

context>

<connector

connector

connector

connectorname="jms_connector"

className="org.mule.providers.jms.activemq.ActiveMqJmsConnector

ActiveMqJmsConnector

ActiveMqJmsConnector

ActiveMqJmsConnector">

<properties>

<property name="persistentDelivery" value="true" />

<property name="persistentDelivery" value="true" />

<property name="specification" value="1.1" />

<property name="maxRedelivery" value="5" />

<container-property name="connectionFactory"

reference="amqConnectionFactory

amqConnectionFactory

amqConnectionFactory

amqConnectionFactory" />

</properties>

</connector

/connector

/connector

/connector>

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 51: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

A-side spring context & active m

q config

51

<bean

bean

bean

beanid="amqConnectionFactory

amqConnectionFactory

amqConnectionFactory

amqConnectionFactory"

class="org.apache.activemq.ActiveMQConnectionFactory

ActiveMQConnectionFactory

ActiveMQConnectionFactory

ActiveMQConnectionFactory">

<broker

broker

broker

brokerbrokerName="amq

amq

amq

amq- ---distr2

distr2

distr2

distr2" persistent="true" useJmx="false"

xmlns="http://activemq.org/config/1.0">

<transportConnectors

transportConnectors

transportConnectors

transportConnectors>

<transportConnector uri="tcp://localhost:55502

tcp://localhost:55502

tcp://localhost:55502

tcp://localhost:55502" />

</transportConnectors>

class="org.apache.activemq.ActiveMQConnectionFactory

ActiveMQConnectionFactory

ActiveMQConnectionFactory

ActiveMQConnectionFactory">

<constructor-arg

value="vm://localhost?brokerConfig=xbean:activemq

vm://localhost?brokerConfig=xbean:activemq

vm://localhost?brokerConfig=xbean:activemq

vm://localhost?brokerConfig=xbean:activemq- ---distr2.xml

distr2.xml

distr2.xml

distr2.xml" />

</bean

/bean

/bean

/bean>

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

</transportConnectors>

<networkConnectors

networkConnectors

networkConnectors

networkConnectors>

<networkConnector uri="static://(tcp://localhost:55501)

static://(tcp://localhost:55501)

static://(tcp://localhost:55501)

static://(tcp://localhost:55501)" />

</networkConnectors

/networkConnectors

/networkConnectors

/networkConnectors>

</broker

/broker

/broker

/broker>

Page 52: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

52

mule axis provider

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 53: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

adding an axis endpoint to the distributed esb5

3

soap

Z

service

SLSBeans

Z reviews

csv

file

Review

amq

mule

axis

Z reviews

csv

soap

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

file

sys

amq

broker

mule

broker

Z reviews

csv

jms

Page 54: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

axis w

ebservice endpoint & transform

er

54

<global

global

global

global- ---endpoints

endpoints

endpoints

endpoints>

<endpoint name="ws_root

ws_root

ws_root

ws_root"

<transformers

transformers

transformers

transformers>

<transformer name="args2s

args2s

args2s

args2s"

<endpoint name="ws_root

ws_root

ws_root

ws_root"

address="axis:http://localhost:8008/service

axis:http://localhost:8008/service

axis:http://localhost:8008/service

axis:http://localhost:8008/service" />

</global

/global

/global

/global- ---endpoints

endpoints

endpoints

endpoints>

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

<transformer name="args2s

args2s

args2s

args2s"

className="util.esb.mule.MethodArgsToFirstStringArgument

MethodArgsToFirstStringArgument

MethodArgsToFirstStringArgument

MethodArgsToFirstStringArgument" />

</transformers

/transformers

/transformers

/transformers>

Page 55: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

exposing a component as a soap w

ebservice

<mule

mule

mule

mule- ---descriptor

descriptor

descriptor

descriptorname="reviewsGateway"

implementation="bookreview.integration.esb.ReviewsGatewayImpl

ReviewsGatewayImpl

ReviewsGatewayImpl

ReviewsGatewayImpl">55

implementation="bookreview.integration.esb.ReviewsGatewayImpl

ReviewsGatewayImpl

ReviewsGatewayImpl

ReviewsGatewayImpl">

<inbound-router><global-endpoint name="ws_root

ws_root

ws_root

ws_root"/></inbound-router>

<outbound-router>

<router className="....OutboundPassThroughRouter">

<global-endpoint name="..." transformers="args2s

args2s

args2s

args2so2jms" />

</router>

</outbound-router>

<properties>

<properties>

<property name="style" value="Wrapped" />

<property name="use" value="Literal" />

<property name="serviceNamespace"

value="urn:bookreview:service"/>

</properties>

</mule

/mule

/mule

/mule- ---descriptor

descriptor

descriptor

descriptor>

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 56: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

the w

sdl-defining component and interface

56

public interface ReviewsGateway

ReviewsGateway

ReviewsGateway

ReviewsGateway{

public class ReviewsGatewayImpl

ReviewsGatewayImpl

ReviewsGatewayImpl

ReviewsGatewayImplimplements ReviewsGateway {

void submitReviewsInTextFormat(String reviews);

} mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

public void submitReviewsInTextFormat(String reviews) {

// do not alter message

}

}

Page 57: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

a transform

er that extracts the first string arg

public class MethodArgsToFirstStringArgument

MethodArgsToFirstStringArgument

MethodArgsToFirstStringArgument

MethodArgsToFirstStringArgumentextends

AbstractTransformer {

57

AbstractTransformer {

public MethodArgsToFirstStringArgument()

MethodArgsToFirstStringArgument()

MethodArgsToFirstStringArgument()

MethodArgsToFirstStringArgument(){

registerSourceType(Object[].class);

setReturnClass(String.class);

} @Override

protected Object doTransform(Object src, String encoding)

Object doTransform(Object src, String encoding)

Object doTransform(Object src, String encoding)

Object doTransform(Object src, String encoding)

throws TransformerException {

final Object[] args = (Object[]) src;

final Object[] args = (Object[]) src;

for (final Object arg : args) {

if (arg instanceof String) return arg;

} return null;

}

} mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 58: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

58

parsing, mapping, form

atting, the data m

apping service

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 59: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

our message transform

ation problem

59

reviewer

book id

mark

review

reviewer

book id

mark

review

First3 Last3

Z2

5Sim

ply Terrible

Person

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Review

rating

text

Person

Book

Page 60: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

conceptualising m

essage transform

ation

•in gen

eral m input messages are to be transform

ed to n

60

output messages

▫using aggregators (a framew

ork for which is part of mule) the

m input messages can always be combined

to one message

=> 1 input is transform

ed to n output messages

•pre-transform

ation step: detecting the input message

form

at/type and version

▫java instanceof, xml namespace uri, xml dtd, xpath

expression,

▫java instanceof, xml namespace uri, xml dtd, xpath

expression,

type field, filename pattern

▫need access to "store" of supported

message form

ats/types

▫usually followed

by content-based routing to suitable

transform

er

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 61: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

conceptualising m

essage transform

ation

•steps in m

essage transform

ation:

61

▫step 1: parsing the input message, thereby validating it

�jaxb, java deserialisation, flatpack file parser

▫step 2: mapping input fields to output fields

�in gen

eral m-to-n

�restrict to 1-to-1 m

appings here for sake of simplicity

�distinguish 3 types of mapping depen

den

t on need for access to

mapping data store/services and access to application services:

mapping data store/services and access to application services:

�no need for mapping data store/services

▫split "firstName lastName" into "firstN

ame" and "lastName"

▫copy "review" field into "text" field

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 62: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

conceptualising m

essage transform

ation

�lookup in m

ostly static and application-indepen

den

t "referen

ce data"

mapping data store

62

mapping data store

▫mapping "mark" field to "rating" field

�lookup in dynamic and application-depen

den

t "live data" mapping data

store or invocation of lookup (finder) application services

▫mapping "book id" field to isbnor internal book id or Book object

▫lookup Book object (or id) by isbn

▫lookup Person object (or id) by "firstN

ame" and "lastName"

▫step 3: creating/form

atting the output message(s)

�java new

or factory, jaxb, xslt output

▫steps 1&

2 are depen

den

t on the input message form

at

steps2&3 are depen

den

t on the output message form

at(s)

�either accept that each transform

er is depen

den

t on input and

output message form

at(s)

�or decouple through interm

ediary form

at (not discussed here)

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 63: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

a sim

ple data m

apping data store and service6

3

mappedtypefromvaluespace

fromvalueto value

mappedtypefromvaluespace

fromvalueto value

RATIN

GAUSTRIA

N_MARKS

1GOOD

RATIN

GAUSTRIA

N_MARKS

5UGLY

ISBN

ZSOLNAY

Z1

isbn1

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

MappingService

String getMapped

Value(Mapped

Typetype, String fromValueSpace,

String fromValue)

Page 64: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

positioning the data m

apping service

•for perform

ance reasons we do not accept many fine-

64

grained rem

ote calls during m

essage transform

ation

▫=> data m

apping service and transform

er m

ust be co-located

�access through local slsb or spring service

•2 possible solutions:

▫im

plemen

t data m

apping service as an integral part of the

application and deploy the transform

er (and hen

ce m

ule) with

the application

the application

�mule can be deployed as a norm

al library (jar) within any war/ejb-

jar/ear or as a jca resource adapter (rar) globally to the app server

(not jboss)or within an ear

▫im

plemen

ting the data m

apping service as an integral part of

the esb (mule) which hosts the transfomer

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 65: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

co-locating application, transform

er and m

ule6

5

data

file

sys

z_filedrop

f2s

splitter

Z reviews

csvfile

LineSplitter

Z reviews

csv

Z review

csv

Z review

csv

Z review

csv

Mapping

SLSBean

Person

SLSBean

Book

SLSBean

mule

transform

er

Transformer

mule rarear

mapping

data store

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Review

SLSBean

Review

Splitter

SLSBean

...Transformer

Page 66: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

co-locating application, transform

er and m

ule

•not only data m

apping service but also all other services are

66

co-located

▫PersonSLSBean, BookSLSBean, ReviewSLSBean

•any change to a supported m

essage form

at (and hen

ce

transform

er) or the addition of a new

message form

at or

version thereof (and hen

ce transform

er) requires changing

and re-deploying the application

•very hard to support several versions of the same message

•very hard to support several versions of the same message

form

at if they are m

apped to java classes of the same fully-

qualified class name!

•complicates deploymen

t considerably

▫jboss and m

ule have conflicting jar file depen

den

cies

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 67: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

data m

apping service w

ithin stand-alone m

ule6

7

Z review

csv

Z review

file

sys

z_filedrop

f2s

splitter

Z reviews

csvfile

transform

er

LineSplitter

Z reviews

csv

csv

Z review

csv

Z review

csv ...Transformer

Person

SLSBean

Book

SLSBean

mule

Review

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Review

SLSBean

Mapping

Service

data

mapping

data store

Page 68: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

data m

apping service w

ithin stand-alone m

ule

•depen

den

cies on input message form

ats now confined to

68

transform

er(s) deployed in stand-alone mule

▫can m

odify/add m

essage form

ats without changing application

•data m

apping store and service now separated from

application

▫can be tuned

irrespective of application

�in particular caching (and hen

ce m

emory consumption) can be

configured to fully ben

efit the mapping service!

configured to fully ben

efit the mapping service!

▫but how is the dynamic "live data" part of the mapping data

store kept in sync with the application?

•lookup/finder-style application services needed by

transform

er are still accessed rem

otely

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 69: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

data m

apping service and lookup services for

application data w

ithin stand-alone m

ule

69

Z review

csv

Z review

Review

file

sys

Review

z_filedrop

f2s

splitter

Z reviews

csvfile

transform

er

LineSplitter

Z reviews

csv

csv

Z review

csv

Z review

csv ...Transformer

Person

SLSBean

Book

SLSBean

mule

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Review

SLSBean

Mapping

Service

data

mapping

data store

mapping updater

Person

Lookup

Service

Book

Lookup

Service

changes

Page 70: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

data m

apping service and lookup services for

application data w

ithin stand-alone m

ule

•all services needed by transform

er(s) are deployed in stand-70

alone mule and accessible locally

•"m

apping updater" componen

t in m

ule subscribes to one or

more change notification topics (publish-subscribe

channels [2]; observer pattern) in application server where

the application publishes changes to its domain m

odel

▫"m

apping updater" keeps data m

apping data store in-sync with

application "live data" at all tim

esapplication "live data" at all tim

es

•data m

apping data store only keeps data it needs for the

data m

apping service and the lookup services built on it

▫table structure and caching strategy can be optimised

for

mapping

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 71: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

application layers w

/ publisher layer

71

service

ReviewService, ...

ejb

ReviewSLSBean, ...java client

mule

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

domain

Book, Person, Review

repository

ReviewRepository, ...

hibernate

ReviewService, ...

publisher

PersonPublisher, ...

domain

Book, ...

jms

Page 72: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

72

capitalising on the publisher layer and the distributed esb

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

Page 73: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

application layers supporting integration

73

service

ReviewService, ...

ejb

ReviewSLSBean, ...java client

mule

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

domain

Book, Person, Review

repository

ReviewRepository, ...

hibernate

ReviewService, ...

publisher

PersonPublisher, ...

domain

Book, ...

jms

Page 74: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

feeding data to Z through the publisher layer7

4

Zservice

SLSBeans

Z reviews

csv

file

Review

amq

mule

changes

Z -> A

Z <-A

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007

file

sys

amq

broker

mule

broker

Z reviews

csv

jms

changes

Page 75: style integration front-end to java · PDF filemule as an esb-style integration front-end to java eeapplications geraldloeffler, phd mba senior architect/developer objectlab financial

what we did not talk about

•transaction dem

arcation with m

ule

75

▫begin on inbound-router's en

dpoint

▫commit on outbound-router's en

dpoint

▫rollback through exception strategy

•security

▫most importantly securing access to endpoints

•operating a m

ule-based integration solution

▫jm

x agen

t comes with m

ule

▫"console" available as a commercial product

•mule threading, queu

ing and componen

t pooling

•most of the routers and componen

ts that come with m

ule

mule and integrating java ee applications | gerald loeffler | ejug london | june 2007