EAI and Spring Integration
Josh Long
Architect, Software Engineer
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/4czgdwAgenda
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
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
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
How do JEE solutions stack up on…
• Messaging
• RPC
• Integration with Homogeneous Systems
• Integration with Heterogeneous Systems
• Mainframe systems?
• Security
• Flexible routing
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
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.
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
Existing Architecture
Envisioned Architecture
Let's use an ESB!
Spring Integration Solution
DEMO
•
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
A little background information:
You'll typically deal with three things in an
integration solution:
Channels
Endpoints
Adapters
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.
Adapters:
In xml:
We need to connect something to this channel.
An adapter knows how to deal with some external
system
Service Adapter:
In xml:
This allows you to invoke java code as a result of
a message of a certain type arriving.
Spring Integration Solution
Spring Integration Solution
File Drop Solution (XML)
}
channels
}
beans
Spring Integration Solution
File Drop Solution (XML)
}
beans
Declaring a few beans that contain annotations. – This makes Spring recognize them
Spring Integration Solution
File Drop Solution (XML)
}
channels
Spring Integration Solution
Take a look at the beans themselves.
File Solution (Java): The Splitter:
Spring Integration Solution
Take a look at the beans themselves.
File Solution (Java): The Transformer:
Spring Integration Solution
Take a look at the beans themselves.
Spring Integration Solution
Configuration for the JMS client. You'd write this whether you were using Spring
Integration or not.
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 Solution
Let'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