EAI with Spring Integration -...

Preview:

Citation preview

EAI and Spring Integration

Josh LongArchitect, Software EngineerJoshLong.com

Josh@JoshLong.com

Who am I? Josh Long A developer with an architect's hat on Blog: www.joshlong.com Artima.com Blog: http://tinyurl.com/4czgdw Any questions?

Agenda Talk a bit about EAI

Give a Brief History of EAI

Enumerate the capabilities of an ESB Talk to you about what the landscape of ESBs

Introduce Spring Integration (you can cheer)

Introduce a case study: a user management service Show some code and a demo Questions (please feel free to ask)

What is EAI Enterprise Application Integration

Been around for as long as disparate computing paradigms have

EAI is integration of services and / or data. Enterprise Application Integration platforms have

changed names Now known as: an Enterprise Service Bus (ESB)

Please update your buzzword dictionary.

Types of EAI: File Transfer Shared Database Remote Procedure Call Messaging

Common ESB Capabilities Location Transparency Transport Conversion Message Transformation / Routing / Enhancement Security

Spring Security integration‟s on the roadmap

Monitoring and management you might use JMX for Spring Integration

Process management (BPMs, orchestration) Complex Event Processing

DO NOT USE: The foundation of all SOA architectures They encourage the creation of centralized

silos of information and services This is anti-SOA

Best used with an eye towards exposing hidden applications and services

Not the fastest solution since, by definition, they're a level of indirection

USE: You'd use an ESB to integrate applications and

data that don't naturally fit well together. Reduce architectural spaghetti

Applicability of an ESB:

How do JEE solutions stack up on…• Messaging

• RPC

• Integration with Homogeneous Systems

• Integration with Heterogeneous Systems• Mainframe systems?

• Security

• Flexible routing

* Babel fish from Hitchhiker's Guide to the Galaxy

Spring Integration Spring Integration is a new addition to the Spring Portfolio

Provides support for SOA, EDA and EAI Too many buzzwords?

It just went live with a 1.0 late in 2008.

Provides philosophical consistency with core Spring

principles. Spring Integration is an API geared towards building ESB -centric

solutions, not another name for the Spring remoting APIs.

The ESB Landscape Traditional EAI solutions from

the likes of TIBCO, Axway,

WebMethods

Open source / Java-centric

solutions like ServiceMix,

PEtALS, OpenESB, JBossESB,

Mule (and of course Spring Integration) The alternatives: solutions

strung together with bailing wire

and tape, a veritable Rube

Goldberg machine * Rube Goldberg solution -- you’ve never built

something like this, have you? Really??

Case Study: Introduction The application is the central user authorization and

management hub for all customers in the suite

Plans include provision of single sign on, etc

Needs to be flexible in the future.

Case Study: History Version 1.0

Written on „raw‟ JEE 1.4

Remoting provided by EJB 2.x

ORM-ish functionality achieved using CMP Entity Beans

Development took 1,000 rat years

Version 2.0 Fundamental pieces were reworked

No rats were harmed. Developers, however…

Version 3.0 (this is the one we‟re going to address…)

Provide integration with newly assimilated PHP site /

application.

Provide faster integration with Java application using JMS

Case Study: 3.0 Analysis Provide integration with PHP Site

Application already supports CSV exports

Third party: don‟t have the source

Provide faster integration with Java application The Java application gets too much traffic;

enrollments can't keep up.

Use temporal decoupling: buffer the requests

using JMS

Existing Architecture

Case Study

Envisioned Architecture

Case Study

Let's use an ESB!

Case Study

Spring Integration Solution

DEMO

TIME!!

• Spring Integration uses standard Spring XML • Idiomatic configuration: annotations, schema.• DSLs to go• Spring Integration is embedded: deploy Spring• Integration with your app; you don‟t deploy your

application to Spring Integration

Spring Integration

A little background information:

Spring Integration

You'll typically deal with three things in an integration solution:

Channels Endpoints Adapters

Spring Integration

Spring Integration

{your code here}

This all happens in a Spring Application Context, just like any other Spring configuration:

Spring Integration

Channels: In xml:

• Pretty useless.

• It's just an abstract concept at this point.

Something to connect to, but no real indication is

provided as to how.

• That's next...

Adapters:In xml:

We need to connect something to this channel. An adapter knows how to deal with some external

system

Spring Integration

Service Adapter:In xml:

This allows you to invoke java code as a result of a message of a certain type arriving.

Spring Integration

Spring Integration SolutionFile Drop Solution (XML)

Spring Integration SolutionFile Drop Solution (XML)

}channels

}beans

}components

Spring Integration Solution

File Drop Solution (XML)

}beans

Declaring a few beans that contain annotations. – This makes Spring recognize them

Plus, you can reference those beans from other beans.

Spring Integration Solution

File Drop Solution (XML)

}channels

Declare channels for use later.

Spring Integration Solution

Spring Integration SolutionTake a look at the beans themselves.File Solution (Java): The Splitter:

Spring Integration SolutionTake a look at the beans themselves.File Solution (Java): The Transformer:

Spring Integration SolutionTake a look at the beans themselves.File Solution (Java): The Service Activator:

Spring Integration Solution

Configuration for the JMS client. You'd write this whether you were using Spring Integration or not.

JMS Solution (XML)

Spring Integration Solution

1: tells SI to pop messages off the JMS queue 2: tells SI to transform incoming JMS messages into EnrolledUsers. 3: tells SI to call the same service activator that we saw last time, and call enrollments.

JMS Solution (XML)The relevant XML

Spring Integration SolutionLet's again take a look at the beans themselves:JMS Solution (Java): The Transformer

Where to go From Here: Spring Batch• Spring Batch

• Spring Batch provides a standard infrastructure for batch processing (i.e., large data payloads)

• Data can be partitioned and processed in chunks, which then might be fed to an event bus.

• The reason for this is simple: Spring Integration encourages a (Staged) Event Driven Architecture, but a file with 20 million rows isn‟t an event. It‟s too coarse. Use Spring Batch to make manageable.

• The other way around is possible too:

• The ESB may produce output that, taken together, is too large or that would be better suited for batch processing infrastructure.

• You might use a correlation ID to have a processed message re-enter the bus and resume processing or routing.

Where to go From Here: Workflow• jBPM and Spring Modules Support

• Spring Batch can glue disparate subsystems together, enabling the components to send messages.

• Once inside one subsystem, however, complex, stateful processing may be required.

• Nested states, recursion, etc

• An ESB is not ideal for very complex state management; messages are either going in or out.

• Use a workflow engine (JBoss jBPM is a fine example) to handle complex management of the message and application state.

• You might use a correlation ID to have a processed message re-enter the bus and resume processing or routing.

Mark Fisher, Iwein Fuld and the SI developers for framework and support “Enterprise Integration Patterns” “Open Source ESBs in Action”

Acknowledgments

The

End

Questions?

Recommended