Spring Integration HandsOn
Mak Bhatamrekar
http://github.com/makrand-bkar
AJCP
http://meetup.com/my-ajcp
Atlanta Java Concept Pros
Agenda
• Introduction
• Message Channel
• End Points
• Example
• Recap
• Applications Need to Talk
• Strategies
– File Sharing
– Single Database
– Messaging
• Most common Approach for
EAI and Basis of SI
• Messages can be Enriched,
Transformed, Routed, Filtered
SI History
• Nov 2007 – First Commit
• Nov 2008 – 1.0
• Nov 2010 – 2.0
• Jun 2013 – 2.2.4
Why Spring SI
• Spring has a good footprint
• Large Range of EndPoint Adapters
– File systems, FTP, REST, Sockets etc
• Light Weight
• POJO Based
• Non Intrusive
• Zero Configuration

Before
After
Building Blocks
SI Building Blocks
• Messages
• Channels
• EndPoints
Message
• public org.springframework.integration;
public interface Message<T>{
MessageHeaders getHeaders();
T getPayload();
}
• MessageBuilder – Spring Impl
Message Channel
• Decouples Consumers and Producers
• Point to Point or Pub/Sub
• Enforces Data Type Consistency
Spring Integration Has Pipes And Filters as Core Integration Pattern
<beans>
…
<int:channel id=“newAccounts”/>
</beans>
Message Channel
• P2P
– PollableChannel
• receive()
• receive(long timeout)
– Queue/Priority/Rendezv
ous
• Pub / Sub
– Subscribable Channel
• Subscribe()
• UnSubscribe
– MessageHandler
• handleMessage(msg)
• Message Buffering
• Message Channel Intf
boolean send(long timeout)
Channel Selection
• Sharing Context -
– ThreadLocal / ThreadContext / Stack
• Atomic Boundaries
• Buffering
Enterprise Integration Patterns
• Pipes And Filter
• Bridge
EndPoints
• Produces /Consumes Messages For Channel
• Out of the box endpoints
– Adapters, Transformers
– Filters, Routing , Splitter, Aggregation
– Message Enricher, Delayer
• UniDirectional / BiDirectional
– Adapters – UniDirection
– Gateways - BiDirectional
Transformer
Message Adapter
Service Activator
<int:service-activator input-channel="positions-channel"
ref="newPositionProcessor"
method="processNewPosition">
</int:service-activator>
Message Translator/ Transformer
<int:object-to-map-transformer
input-channel="in-channel"
output-channel="stdout">
</int:object-to-map-transformer>
• E.G Map, Object To String, XML, JSON
• Custom Transformers Can be added by Annotations too like @Transformer
Rube Goldberg Scenario
Performance
Performance – MS Value
• Amazon – 100ms == 1% of lost sales
• Yahoo – 400 ms == drops traffic 5-9%
Typical Requirements
• Latency Requirements
– Few ms +
• Throughtput Requirements
– Message type dependant
– 10s of hundreds of thousands
Source : Andrew
Elmorehttp://www.springsource.org/node/22599
Simple Test Stats
• Results
– Throughtput – 350K messages/ sec
– Latency - < 4us
References
• Spring Integration Homepage http://www.springsource.org/spring-
integration
• Spring Expression
http://static.springsource.org/spring/docs/3.0.x/reference/expressions.html
• http://www.javacodegeeks.com/2012/06/rube-goldberg-spring-
integration_22.html
Spring Integration Hands On
Mak Bhatamrekar
github :http://github.com/makrand-bkar
twitter : mak-bkar
url : www.careerinjava.com
http://meetup.com/my-ajcp
Atlanta Java Concept Pros

Sprintintegration ajip

Editor's Notes

  • #3 Whats the Problem we are trying to solve
  • #4 Transport - Waiter Takes Order and Moes to BaristaAsynchronous - Multiple ActiviesTranslation - Menu Item -&gt; Number -&gt; RecipeRouting - Orders Arrive Back at Table
  • #6 Bruice Distributed System there are 3 ConcernsConsistency,Availablity – Every request has a guaranteed response, ParitionTolerence
  • #8 Advantages-- Parallel-- Can Easily Add New Logic
  • #10 Messages carry informationChannel Represents the Locations where Msg is being sent
  • #15 Buffering Message – Variable Load , ability to withstand highloads is an important performance factor
  • #16 - Bridge Supports Connection of Two Channels