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 andriy_kryvtsun@epam.com @akryvtsun
Enterprise Application Integration (EAI) ● What? ● Where? ● When?
EAI styles File Transfer Shared Database Remote Procedure Invocation Message-oriented middleware (MOM)
MOM components ● Messages ● Channels ● Endpoints ● Transformations ● Routing ● Configuration
EAI Patterns
Coffee Shop Example cafe orders order splitter drinks drinks router cold drinks hot drinks cold drinks serving hot drinks serving prepared drinks order aggregator deliveries
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 DSL Demo
Numbers Polling Consumer Even Numbers Filter Header fields Enricher Wire Tap Output Number to String transformer File Output Even Numbers Processor
Java DSL Advantages ● expressiveness ● strict types ● compatibility with Java 8 lambdas, Spring Java DSL and Spring Boot
Java DSL Disadvantages
Header fields Enricher Wire Tap Output Number to String transformer File Output FTP OutputNumber to String transformer Numbers Polling Consumer Even Numbers Router ‘TRUE’ ‘FALSE’ Prime Numbers Filter Even and Prime Numbers Processor
1. Verbosity
1. Verbosity Solution - flow splitting - bean logic encapsulation
2. Limitation
Header fields Enricher Wire Tap Output Number to String transformer File Output FTP Output Number to String transformerNumbers Polling Consumer Number Type Router JDBC Output Even Number Channel Prime Number Channel Palindrome Number Channel Null Channel File Name Enricher
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

Spring Integration: from XML to Java DSL