Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Spring framework 5: New Core and Reactive features

4,791 views

Published on

Spring Framework 5 review of new core features.

Published in: Engineering

Spring framework 5: New Core and Reactive features

  1. 1. SPRING FRAMEWORK 5 Aliaksei Zhynhiarouski
 Ciklum, 3.2017
  2. 2. AGENDA TIME TO LEARN MORE ▸ What awaits us with Spring 5? ▸ “Enterprise” challenges and Reactive changes ▸ Coding!
  3. 3. HISTORY Started at 2002 by Rod Johnson & Juergen Hoeller Company behind: Interface21, SpringSource, Pivotal
  4. 4. 2017 SPRING FRAMEWORK 4.3 Last release in 4.3 branch support until 2019 will work with JDK 6,7,8,9 and Tomcat 6-9 Spring Framework 5 M5 Reactor 3
  5. 5. WHAT’S NEW SPRING FRAMEWORK 5.0 Roadmap ‣ 5.0 M5 available now ‣ 5.0 RC1: April 2017 ‣ 5.0 GA expected at in June (wait for JDK9 GA) JDK 8+, Servlet 3.1+, JMS 2.0+, JPA 2.1+, JUnit 5 Major baseline updates with Java EE 7
  6. 6. WHAT’S NEW SPRING FRAMEWORK 5.0 Core updates ‣ Java 8 in the core ‣ Java 9 full compatibility, jigsaw Web & Infrastructure ‣ HTTP/2 on client and server HTTP/2 Comes to Java ‣ Functional vs Annotation style ‣ Lambda oriented HTTP routing & processing ‣ spring-webflux ‣ Kotlin SPR-13716
  7. 7. WHAT’S NEW JDK9 ‣ Many general improvements 
 * Compact Strings, G1, etc… ‣ Spring 4.3 and 5.0 can run on JDK9 ‣ Frameworks jar’s as Jigsaw-compliant modules on module path
 * Application module-info.java may refer framework modules

  8. 8. WHAT’S NEW HTTP/2 ‣ Servlet 4.0 – September 2017
 * enforce support for HTTP/2 in Servlet containers
 * API for stream prioritization and push resources ‣ Tomcat/Jetty/Undertow
 * native HTTP/2 since in current Servlet 3.1 
 * Tomcat 8.5/9.0, Jetty 9.3, Undertow 1.3/1.4 ‣ Spring Framework 5.1 will support Servlet 4.0
 * as well as support for new JDK HTTP client
 * 5.0 focus on native HTTP/2 on top of Tomcat, Jetty, Undertow

  9. 9. WHAT’S NEW FUNCTIONAL STYLE ‣ Spring 4.3 summarize annotation history
 * annotation based component model ‣ Spring 5 provides functional style API as an alternative
 * pragmatic bean registration and endpoint composition 
 * no need for annotations or scanning ‣ Even better with Kotlin
 * Java 8 style is nice
 * Spring Kotlin’s extension make code even more concise

  10. 10. JAVA KOTLIN
  11. 11. ENTERPRISE CHALLENGES DO WE NEED TO CHANGE? “Enterprise” challenges and Reactive changes II
  12. 12. ENTERPRISE CHALLENGES BLOCKING IO LATENCY REAL MATTERS RESOURCE UTILIZATION IMPERATIVE CODE
  13. 13. SERVLET CONTAINER IN NUTSHELL
  14. 14. SERVLET CONTAINER IN NUTSHELL
  15. 15. FIX SERVLET CONTAINERS
  16. 16. THERE IS ANOTHER WAY
  17. 17. REACTOR/EVENT-LOOP
  18. 18. REACTOR/EVENT-LOOP
  19. 19. CURRENT STATE AND CHALLENGES NON-BLOCKING IO LATENCY REAL MATTERS RESOURCE UTILIZATION REACTIVE CODE
  20. 20. REACTIVEX CRASH COURSE Stream Abstraction ▸ Functional, declarative programming model ▸ Combine, transform, reduce sequences ▸ Focus on what, not how Stream (JDK8) ▸ Efficiently process collections ▸ Pull based and usable only once ▸ For non latency or infinite Reactive Library ▸ Stream(JDK8) like API ▸ Push based ▸ Latency sensitive and infinite seqs
  21. 21. Flux.fromIterable(Arrays.asList("foo", "bar", "foo")) .map(String::toUpperCase) .flatMap(s -> Flux.just(s.concat("!"))) .distinct() .publishOn(Schedulers.elastic()); RX
  22. 22. HOW TO WRITE NON BLOCKING REACTIVE STREAMS ▸ Specification for non-blocking libs interoperability ▸ Collaborative effort: Netflix, Pivotal, RedHat, Twitter, Lightbend ▸ JDK9 adoption java.util.concurrent.Flow ▸ Only 4 Interfaces http://www.reactive-streams.org https://spring.io/blog/2016/04/19/understanding-reactive-types
  23. 23. REACTOR 3: REACTIVE STREAMS WITH BACKPRESSURE
  24. 24. FLUX<T>
  25. 25. MONO<T>
  26. 26. SPRING 5 SPRING + REACTOR + RX = 🌞
  27. 27. UNDER THE HOOD
  28. 28. REACTIVE STREAMS EVERYWHERE
  29. 29. REACTIVE STREAMS EVERYWHERE
  30. 30. JAVA PROFESSIONALS BY
  31. 31. LINKS Aliaksei Zhynhiarouski
 twitter: @a_lithium http://www.reactive-streams.org https://spring.io/blog/2016/04/19/understanding-reactive-types Notes on Reactive Programming Part I Notes on Reactive Programming Part II Notes on Reactive Programming Part III https://github.com/aliaksei-lithium/spring5demo

×