Upload
makarand-bhatambarekar
View
509
Download
3
Tags:
Embed Size (px)
Citation preview
Spring Integration HandsOnMak Bhatamrekar
http://github.com/makrand-bkar
AJCP
http://meetup.com/my-ajcpAtlanta Java Concept Pros
Agenda
• Introduction• Message Channel• End Points• Example• Recap
Spring Integration • 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/Rendezvous
• 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 Expressionhttp://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 OnMak Bhatamrekar
github :http://github.com/makrand-bkartwitter : mak-bkar
url : www.careerinjava.com
http://meetup.com/my-ajcpAtlanta Java Concept Pros