spring framework 5: new core and reactive features

32
SPRING FRAMEWORK 5 Aliaksei Zhynhiarouski Ciklum, 3.2017

Upload: aliaksei-zhynhiarouski

Post on 21-Mar-2017

81 views

Category:

Engineering


1 download

TRANSCRIPT

Page 1: Spring framework 5: New Core and Reactive features

SPRING FRAMEWORK 5Aliaksei Zhynhiarouski

Ciklum, 3.2017

Page 2: Spring framework 5: New Core and Reactive features

AGENDA

TIME TO LEARN MORE

▸ What awaits us with Spring 5?

▸ “Enterprise” challenges and Reactive changes

▸ Coding!

Page 3: Spring framework 5: New Core and Reactive features

HISTORY

Started at 2002 by Rod Johnson & Juergen Hoeller

Company behind: Interface21, SpringSource, Pivotal

Page 4: Spring framework 5: New Core and Reactive features

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 M5Reactor 3

Page 5: Spring framework 5: New Core and Reactive features

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

Page 6: Spring framework 5: New Core and Reactive features

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

Page 7: Spring framework 5: New Core and Reactive features

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

Page 8: Spring framework 5: New Core and Reactive features

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

Page 9: Spring framework 5: New Core and Reactive features

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

Page 10: Spring framework 5: New Core and Reactive features

JAVA

KOTLIN

Page 11: Spring framework 5: New Core and Reactive features

ENTERPRISE CHALLENGES

DO WE NEED TO CHANGE?

“Enterprise” challenges and Reactive changesII

Page 12: Spring framework 5: New Core and Reactive features

ENTERPRISE CHALLENGES

BLOCKING IO

LATENCY REAL MATTERS

RESOURCE UTILIZATION

IMPERATIVE CODE

Page 13: Spring framework 5: New Core and Reactive features

SERVLET CONTAINER IN NUTSHELL

Page 14: Spring framework 5: New Core and Reactive features

SERVLET CONTAINER IN NUTSHELL

Page 15: Spring framework 5: New Core and Reactive features

FIX SERVLET CONTAINERS

Page 16: Spring framework 5: New Core and Reactive features

THERE IS ANOTHER WAY

Page 17: Spring framework 5: New Core and Reactive features

REACTOR/EVENT-LOOP

Page 18: Spring framework 5: New Core and Reactive features

REACTOR/EVENT-LOOP

Page 19: Spring framework 5: New Core and Reactive features

CURRENT STATE AND CHALLENGES

NON-BLOCKING IO

LATENCY REAL MATTERS

RESOURCE UTILIZATION

REACTIVE CODE

Page 20: Spring framework 5: New Core and Reactive features

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

Page 21: Spring framework 5: New Core and Reactive features

Flux.fromIterable(Arrays.asList("foo", "bar", "foo"))

.map(String::toUpperCase)

.flatMap(s -> Flux.just(s.concat("!")))

.distinct()

.publishOn(Schedulers.elastic());

RX

Page 22: Spring framework 5: New Core and Reactive features

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

Page 23: Spring framework 5: New Core and Reactive features

REACTOR 3: REACTIVE STREAMS WITH BACKPRESSURE

Page 24: Spring framework 5: New Core and Reactive features

FLUX<T>

Page 25: Spring framework 5: New Core and Reactive features

MONO<T>

Page 26: Spring framework 5: New Core and Reactive features

SPRING 5

SPRING + REACTOR + RX = 🌞

Page 27: Spring framework 5: New Core and Reactive features
Page 28: Spring framework 5: New Core and Reactive features

UNDER THE HOOD

Page 29: Spring framework 5: New Core and Reactive features

REACTIVE STREAMS EVERYWHERE

Page 30: Spring framework 5: New Core and Reactive features

REACTIVE STREAMS EVERYWHERE

Page 31: Spring framework 5: New Core and Reactive features

JAVA PROFESSIONALS BY

Page 32: Spring framework 5: New Core and Reactive features

LINKS

Aliaksei Zhynhiarouskitwitter: @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