spring integration: from xml to java dsl
TRANSCRIPT
Spring Integration:from XML configuration
to Java DSL
Agenda
● Enterprise Application Integration● Message-oriented middleware● Spring Integration framework (SI)● SI Java DSL
– Advantages
– Disadvantages
● Conclusions
whoami
Andriy Kryvtsun
● Senior Software Engineer● 15+ years Java experience
[email protected]@akryvtsun
EnterpriseApplication Integration
(EAI)
● What?● Where?● When?
EAI styles
File Transfer Shared Database
Remote ProcedureInvocation
Message-orientedmiddleware (MOM)
MOM components
● Messages● Channels● Endpoints● Transformations● Routing● Configuration
EAI Patterns
Coffee Shop Example
cafe orders order splitter drinks
drinksrouter
cold drinks
hot drinks
cold drinks serving
hot drinks serving
prepared drinksorder
aggregatordeliveries
MOM implementations
Spring Integration
Mule ESB
Spring Integration
● Founded at 2009
● Lightweight routing and mediation framework ● Low level DSLs● Tight integration with others Spring projects (Spring
DI, Spring XD, Spring Cloud etc.)
DSL types in Spring Integration
● Founded at 2009
● Implements big set of EIPs and endpoints
● Has around 70 contributors
● 8000+ commits in GitHub repo
● The last commit date Apr, 2016
● Founded at 2014
● Implements big set of endpoints and EIPs
● Java 8 lambda support
● 154 commits in GitHub repo
● The last commit date Apr, 2016
● Founded at 2012
● Implements only few endpoints (jms, http, amqp)
● Has 69 commits in GitHub repo
● The last commit date Feb, 2016
● Founded at 2012
● Implements few base endpoints (jms, http, file, jdbc etc.)
● Has 220 commits in GitHub repo
● The last commit date Jun, 2013
XML and Java DSLDemo
Numbers Polling Consumer
Even Numbers
Filter
Header fieldsEnricher
Wire TapOutput
Number toString
transformer
File Output
Even Numbers Processor
Java DSLAdvantages
● expressiveness● strict types ● compatibility with Java 8 lambdas, Spring Java DSL
and Spring Boot
Java DSLDisadvantages
Header fieldsEnricher
Wire TapOutput
Number toString
transformer
File Output
FTP OutputNumber toString
transformer
Numbers Polling Consumer
Even NumbersRouter ‘TRUE’
‘FALSE’
Prime Numbers
Filter
Even and Prime Numbers Processor
1. Verbosity
1. Verbosity
Solution- flow splitting- bean logic encapsulation
2. Limitation
Header fieldsEnricher
Wire TapOutput
Number toString
transformer
File Output
FTP Output
Number toString
transformerNumbers Polling Consumer
NumberType
Router
JDBC Output
Even NumberChannel
Prime NumberChannel
PalindromeNumberChannel
NullChannel
File NameEnricher
2. Limitation
Solution- use hybrid configuration - do it yourself
Repositories structure
Conclusions
References
● 'Enterprise Integration Patterns' book by Gregor Hohpe
– http://www.enterpriseintegrationpatterns.com● 'Spring Integraion in Action' book by Mark Fisher, Jonas Partner
● http://projects.spring.io/spring-integration
– https://github.com/spring-projects/spring-integration● Stack Overflow 'spring-integration' tag
http://stackoverflow.com/questions/tagged/spring-integration
Questions