Slide 1

Slide 1 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Going with Data. Christoph Strobl
 Pivotal Software Inc.
 @stroblchristoph

Slide 2

Slide 2 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ In a nutshell, reactive programming is about
 non-blocking, event-driven applications
 that scale with a small number of threads
 with back pressure as a key ingredient
 that aims to ensure producers to not overwhelm consumers. (Rossen Stoyanchev)

Slide 3

Slide 3 text

The next 60 Minutes Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ - A bit of recent history. - Project Reactor / Spring Data Kay / Spring Framework 5. - Some Code.

Slide 4

Slide 4 text

Sept 28 5.0 GA Oct 2nd Kay GA Sept 25 3.1 GA Sept 21 9 Nov 4th A bit of recent history. Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 2.0 GA 5.0 M1 Jul 2016 Kay M1 Sept 2016 Nov 2016 3.0 GA Sept 2015

Slide 5

Slide 5 text

Imperative Applications Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Slide 6

Slide 6 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ @RestController
 static class PersonController {
 
 PersonRepository repository;
 
 
 
 
 
 
 } @GetMapping("/")
 List listPersons(String name) {
 return repository.findAllByName(name);
 }


Slide 7

Slide 7 text

Total Control Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ {…}

Slide 8

Slide 8 text

Batching Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ {…}

Slide 9

Slide 9 text

Async Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ {…} Dispatcher Thread: Worker A Thread: Worker B Thread: Worker C

Slide 10

Slide 10 text

Reactive Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ {…} Subscriber Publisher Stream

Slide 11

Slide 11 text

Iterator.next() Future.get() Subscriber.onNext(t) Remember Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ vs

Slide 12

Slide 12 text

Reactor 3.1 Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Slide 13

Slide 13 text

Reactive Streams Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Provider of a potentially unbounded number of sequenced elements. Publisher Subscriber A processing stage - actually both a Subscriber and a Publisher. Processor One-to-one lifecycle of a Subscriber subscribing to a Publisher. Subscription

Slide 14

Slide 14 text

Flux findAllByLastname(String lastname) Mono findByEmail(String email) Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Mono (0…1) Flux (0…n) #jürgenized

Slide 15

Slide 15 text

Reactive Applications with Spring Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Framework
 5 Project Reactor
 3.1 Spring Data
 Kay

Slide 16

Slide 16 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Apply familiar concepts
 to an new way of expressing functionality.
 With minimal fluff and surprise!

Slide 17

Slide 17 text

Spring WebFlux Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ @RestController
 static class PersonController {
 
 PersonRepository repository;
 
 
 
 
 
 
 } @GetMapping("/")
 Flux fluxPersons(String name) {
 return repository.findAllByName(name);
 }


Slide 18

Slide 18 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Slide 19

Slide 19 text

Spring WebFlux Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ @RestController
 static class PersonController {
 
 PersonRepository repository;
 
 
 
 
 
 
 } @GetMapping("/")
 Flux fluxPersons(String name) {
 return repository.findAllByName(name);
 }


Slide 20

Slide 20 text

Spring Data Reactive Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ interface Repo extends ReactiveCrudRepository { } Flux findAllByLastname(String lastname); Flux findAllByLastname(Mono lastname); Flux customQuery(String lastname); @Query("{lastname : ?0}"); Flux findAllByLastname(String ln, Pageable page);

Slide 21

Slide 21 text

Reactive Repository Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Mono save(S entity); Mono save(Mono entity); Flux saveAll(Iterable entities); Flux saveAll(Publisher entities); Mono existsById(Mono id); Flux findAll(); Mono count(); Mono deleteById(ID id);

Slide 22

Slide 22 text

Reactive Template (MongoDB) Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ /**
 * Query for a {@link Flux} of objects of type T from the specified collection.
 *
 * @param entityClass the parametrized type of the returned {@link Flux}.
 * @param collectionName name of the collection to retrieve the objects from
 * @return the converted collection
 */
 Flux findAll(Class entityClass, String collectionName); /**
 * Map the results of an ad-hoc query on the collection for the entity class to a 
 * single instance of an object of the
 * specified type. *
 * @param query the query class that specifies the criteria 
 * @param entityClass the parametrized type of the returned {@link Mono}.
 * @return the converted object
 */
 Mono findOne(Query query, Class entityClass);

Slide 23

Slide 23 text

Reactive Streams MongoDB Java Driver Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ /** * Counts the number of documents in the collection according to the given options. * * @param filter the query filter * @return a publisher with a single element indicating the number of documents */ Publisher count(Bson filter); /** * Finds all documents in the collection. * * @param filter the query filter * @return the fluent find interface */ FindPublisher find(Bson filter);

Slide 24

Slide 24 text

Publisher Subscriber Processor Subscription .subscribe(Subscriber) .onSubscribe(Subscription) .request(long) .onNext(T) Reactive Streams Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 1 2 3 4 5

Slide 25

Slide 25 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ It’s Demo Time https://github.com/christophstrobl/going-reactive-with-spring-data

Slide 26

Slide 26 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Reactive is about efficient resource usage. Even if backed with familiar concepts and framework support, 
 it is no free lunch. The price is complexity.

Slide 27

Slide 27 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ More Spring / Reactive at 15:00 Spring Boot 2.0 Web Applications (Stéphane Nicoll) 16:10 The API Gateway is dead! Long live the API Gateway! (Spencer Gibb) 17:30 Reactive Mythbusters With Reactor (Simon Basle) 18:40 Refactor to Reactive with Spring 5 and Project Reactor (Oleh Dokuka) 12:30 Spring Cloud Stream - a new rick and Morty adventure (Dieter Hubau) 12:30 Advanced Client Load Balancing with Spring Cloud (Alejsandr Tarasov) 13:50 A Day in a Life of a Traveling Open Source Developer (Spencer Gibb) 14:30 Boot yourself, Spring is coming (Evgeniy Borisov, Kirill Tolkachev) 17:00 Data Microservices with Spring Cloud (Orkhan Gasimov) Today Tomorrow

Slide 28

Slide 28 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Framework
 5 Project Reactor
 3.1 Spring Data
 Kay Questions ?