Slide 1

Slide 1 text

Let’s do this before we start git clone https://bitbucket.org/rlippolis/spring-web-reactive-workshop reactive-spring-intro -> mvn clean verify mememon-go-client -> npm install mememon-go-server -> mvn clean verify npm install -g angular-cli

Slide 2

Slide 2 text

Making the paradigm-shift to Reactive Programming with Spring 5 Web Reactive Riccardo Lippolis - JDriven Bas W. Knopper - JCore

Slide 3

Slide 3 text

Riccardo Lippolis - JDriven Bas W. Knopper - JCore Making the paradigm-shift to Reactive Programming with Spring 5 WebFlux

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

We need to build better software

Slide 7

Slide 7 text

Reactive Programming

Slide 8

Slide 8 text

Extending the observer pattern

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Manipulating data

Slide 11

Slide 11 text

Java 8 Streams vs. Reactive Streams • A Stream is pull based • It "asks" for items to process • Iterable++ • A Reactive Stream is push based • You are notified when an element is available

Slide 12

Slide 12 text

Backpressure what if you can’t handle the data?

Slide 13

Slide 13 text

Reactor projectreactor.io

Slide 14

Slide 14 text

Reactor • Made by Pivotal! (Spring FTW \0/) • A foundation for asynchronous applications on the JVM • Based on the Reactive Streams Specification (same concepts, different naming) • Latest: 3.0.7.RELEASE

Slide 15

Slide 15 text

Flux and Mono

Slide 16

Slide 16 text

Flux and Mono

Slide 17

Slide 17 text

Examples - Creating Reactive Streams • Arbitrary number of items: Flux flux = Flux. just("Hello", "World!"); • Converting an existing collection: List list = Arrays. asList(1, 3, 5); Flux flux = Flux. fromIterable(list); • Empty stream: Flux.empty();

Slide 18

Slide 18 text

Examples - Manipulating Streams • Filtering Flux.just(1, 2, 3, 4, 5) .filter(n -> n % 2 == 0) .subscribe(System.out::println); // [2, 4] • Transforming Flux.just(1, 2, 3, 4, 5) .map(i -> i * 2) .subscribe(System.out::println); // [2, 4, 6, 8, 10]

Slide 19

Slide 19 text

Reactive Spring Web == Spring WebFlux

Slide 20

Slide 20 text

Spring WebFlux Uses the familiar Spring Web MVC programming model (@Controller, etc.)... ...but with a new reactive, non-blocking engine

Slide 21

Slide 21 text

Current state of implementation • Version: 5.0.0 RC1 (Not production ready!) • Focus on REST (Server & Client) • JSON (Jackson) / XML (JAXB) • SSE streaming • Spring Data Kay M1 • Reactive support for MongoDB, Cassandra and Redis

Slide 22

Slide 22 text

Workshop part 1: Master the koans ● Open the reactive-spring-intro project ● Fix all the tests / koans in: src/test/java/com/jdriven/reactive/exercises

Slide 23

Slide 23 text

Workshop part 2: Mememon Go ● Demo explaining Use case ● Make all the tests pass by implementing the code ● Make the application work :)

Slide 24

Slide 24 text

What’s next? • Support for Reactive types in other Spring projects, e.g.: • Spring Cloud • Spring Security • …? • GA Release • Current release: 5.0.0 RC1 • GA in june/july?

Slide 25

Slide 25 text

Great work everybody!