spring framework 5: new core and reactive features

Post on 21-Mar-2017

74 Views

Category:

Engineering

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

SPRING FRAMEWORK 5Aliaksei Zhynhiarouski

Ciklum, 3.2017

AGENDA

TIME TO LEARN MORE

▸ What awaits us with Spring 5?

▸ “Enterprise” challenges and Reactive changes

▸ Coding!

HISTORY

Started at 2002 by Rod Johnson & Juergen Hoeller

Company behind: Interface21, SpringSource, Pivotal

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

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

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

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

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

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

JAVA

KOTLIN

ENTERPRISE CHALLENGES

DO WE NEED TO CHANGE?

“Enterprise” challenges and Reactive changesII

ENTERPRISE CHALLENGES

BLOCKING IO

LATENCY REAL MATTERS

RESOURCE UTILIZATION

IMPERATIVE CODE

SERVLET CONTAINER IN NUTSHELL

SERVLET CONTAINER IN NUTSHELL

FIX SERVLET CONTAINERS

THERE IS ANOTHER WAY

REACTOR/EVENT-LOOP

REACTOR/EVENT-LOOP

CURRENT STATE AND CHALLENGES

NON-BLOCKING IO

LATENCY REAL MATTERS

RESOURCE UTILIZATION

REACTIVE CODE

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

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

.map(String::toUpperCase)

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

.distinct()

.publishOn(Schedulers.elastic());

RX

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

REACTOR 3: REACTIVE STREAMS WITH BACKPRESSURE

FLUX<T>

MONO<T>

SPRING 5

SPRING + REACTOR + RX = 🌞

UNDER THE HOOD

REACTIVE STREAMS EVERYWHERE

REACTIVE STREAMS EVERYWHERE

JAVA PROFESSIONALS BY

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

top related