reactive spring framework 5

38
SPRING FRAMEWORK 5 FAST AND FURIOUS Aliaksei Zhynhiarouski jProf#12, 2016

Upload: aliaksei-zhynhiarouski

Post on 17-Jan-2017

113 views

Category:

Engineering


2 download

TRANSCRIPT

Page 1: Reactive Spring Framework 5

SPRING FRAMEWORK 5FAST AND FURIOUS

Aliaksei ZhynhiarouskijProf#12, 2016

Page 2: Reactive Spring Framework 5

AGENDA

TIME TO LEARN MORE

▸ History of Spring Framework from version 1 to 5

▸ Current state of “Enterprise” Java and challenges

▸ What awaits us with Spring 5?

▸ Coding!

Page 3: Reactive Spring Framework 5

2002

PROTOTYPE IN THE BOOK

Rod Johnson “Expert One-on-One J2EE Design and Development”with no mention of Spring30k LOC under com.interface21 Check code on Github

Juergen Hoeller open source book code with new name Spring

after J2EE winter

Page 4: Reactive Spring Framework 5

2003

INTERFACE 21 & SPRING 0.9

Page 5: Reactive Spring Framework 5

2004

SPRING 1.0

Others frameworks integration (Struts/Hibernate)

AOP support with AspectJ

new books about Spring

Big growth of popularity

Page 6: Reactive Spring Framework 5

2005

SPRING 1.2.6

400k Downloads

Lead AspectJ now with Spring team

Page 7: Reactive Spring Framework 5

2006

SPRING 2.0 & 1_000_000 DOWNLOADS

Spring Security

Spring Web Flow

Spring LDAP

Page 8: Reactive Spring Framework 5

2007

SPRING 2.5

Investments $10m & 3m Downloads

From Interface21 to SpringSource

Spring Integration is announced

Spring Webservice is announced

Spring Batch is announced

Page 9: Reactive Spring Framework 5

2008

GROOVYAcquired G2One – company behind Groovy & Grails

Spring Batch 1.0

Spring Integration 1.0

Spring Team behind projects like Tomcat, Apache HTTP Server

Cloud Foundry – PaaS providerHyperic – tools for monitoring Java

Page 10: Reactive Spring Framework 5

2009

SPRING 3.0 & VMWARE

SpringSource acquired by VMWare for $420m

Spring 3:

‣ JDK 5+

‣ Modularize uber Jar

‣ Comprehensive REST support

‣ Spring Expression Language

Page 11: Reactive Spring Framework 5

2010-2011

SPRING DATA & SPRING AMQP

VMWare bought RabbitMQ company

spring-data-commons

spring-data-jpa

spring-data-mongoDB

spring-data-redis

Page 12: Reactive Spring Framework 5

2013

SPRING 4.0 & PIVOTALPivotal was born

Reactor 1.0

Spring IO Platform announced

Spring Boot introduced

JDK 8 and WebSocket support

SPR-9044

Page 13: Reactive Spring Framework 5

2014-2015

SPRING BOOT

Spring Boot 1.0 Released

Spring XD 1.0 Released

Bye-Bye Groovy 😥

Spring Cloud available (with Netflix OSS)

Spring Framework 4.2.3 in the end of 2015

Page 14: Reactive Spring Framework 5

2016

SPRING FRAMEWORK 4.3

Last release in 4.3 branch

support until 2020

will work with JDK 6,7,8,9

and Tomcat 6-9

Spring Framework 5 M3Reactor 3

Page 15: Reactive Spring Framework 5

CURRENT STATE AND CHALLENGES

DO WE NEED TO CHANGE?

Page 16: Reactive Spring Framework 5

CURRENT STATE AND CHALLENGES

BLOCKING IO

LATENCY REAL MATTERS

RESOURCE UTILIZATION

IMPERATIVE CODE

Page 17: Reactive Spring Framework 5

SERVLET CONTAINER IN NUTSHELL

Page 18: Reactive Spring Framework 5

SERVLET CONTAINER IN NUTSHELL

Page 19: Reactive Spring Framework 5

FIX SERVLET CONTAINERS

Page 20: Reactive Spring Framework 5

THERE IS ANOTHER WAY

Page 21: Reactive Spring Framework 5

REACTOR/EVENT-LOOP

Page 22: Reactive Spring Framework 5

REACTOR/EVENT-LOOP

Page 23: Reactive Spring Framework 5

HOW TO WRITE NON BLOCKING

CALLBACKS }); }); }); });

COMPLETABLE FUTUREsince JDK 8

Completable Future + java.util.Stream

RX

Page 24: Reactive Spring Framework 5

CURRENT STATE AND CHALLENGES

NON-BLOCKING IO

LATENCY REAL MATTERS

RESOURCE UTILIZATION

REACTIVE CODE

Page 25: Reactive Spring Framework 5

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 26: Reactive Spring Framework 5

ONLY 4 INTERFACES

Page 27: Reactive Spring Framework 5

REACTIVE STREAMS

The core concern of Reactive Streams is handling backpressure.

In a nutshell, backpressure is a mechanism that permits a receiver to ask how much data it wants to receive from the emitter. It allows:

▸ The receiver to start receiving data only when it is ready to process it

▸ To control the inflight amount of data

▸ Efficient handling of slow emitter/fast receiver or fast emitter/slow receiver use cases

▸ To switch from a dynamic push-pull strategy to a push-based only strategy if you request Long.MAX_VALUE elements

Page 28: Reactive Spring Framework 5
Page 29: Reactive Spring Framework 5

SPRING 5

SPRING + REACTOR + RX = 🌞

Page 30: Reactive Spring Framework 5
Page 31: Reactive Spring Framework 5

REACTIVE STREAMS EVERYWHERE

Page 32: Reactive Spring Framework 5

REACTIVE STREAMS EVERYWHERE

Page 33: Reactive Spring Framework 5

UNDER THE HOOD

Page 34: Reactive Spring Framework 5

MONO<T>

Page 35: Reactive Spring Framework 5

FLUX<T>

Page 36: Reactive Spring Framework 5

WHAT’S NEW

SPRING FRAMEWORK 5.0

Core updates‣ Java 8 in the core

‣ Java 9 full compatibility, no jigsaw

Web

‣ HTTP/2 on client and server HTTP/2 Comes to Java

‣ Reactive Streams based controllers

‣ Alternatives to annotated controllers handlers design

‣ Lambda oriented HTTP routing & processing

SPR-13716

Page 37: Reactive Spring Framework 5

WHAT’S NEW

SPRING FRAMEWORK 5.0

Roadmap‣ 5.0 M3 available now

‣ 5.0 RC1: Dec 2016/Jan 2017

‣ 5.0 GA Q1

JDK 8+, Servlet 3.1, JMS 2.0+, JPA 2.1+, JUnit 5

Major baseline updates with Java EE 7

Page 38: Reactive Spring Framework 5

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