Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Going Reactive with Spring Data (JUG Berlin-Bra...

Going Reactive with Spring Data (JUG Berlin-Brandenburg)

This talk covers what a stream is and how reactive data access leverages scalability bounds by applying the most natural way of data access with Spring Data and Project Reactor. If you are a developer looking to consume data in a functional reactive style, this is your chance to gain the experience how your application can benefit from streaming data access and to learn why not everything should be reactive.

Christoph Strobl

April 06, 2017
Tweet

More Decks by Christoph Strobl

Other Decks in Programming

Transcript

  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/ Going Reactive with Spring Data Christoph Strobl | Mark Paluch
  2. 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
  3. 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/ Synchronous Data Access 3 {…} Thread: MAIN
  4. 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/ Synchronous Data Access II 4 {…} Thread: MAIN Batching
  5. 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/ Asynchronous Data Access 5 {…} Dispatcher Thread: MAIN Thread: Worker A Thread: Worker B Thread: Worker C
  6. {…} {…} {…} 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/ Asynchronous Data Access II 6 {…} Dispatcher Thread: MAIN Thread: Worker A Thread: Worker B Thread: Worker C Scaling
  7. 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 Data Access 7 {…} Subscriber Publisher Stream
  8. 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/ 8 Iterator.next() Future.get() Subscriber.onNext(t)
  9. 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 Data Access 9 {…} Stream Thread: MAIN Subscriber Publisher
  10. 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 Data Access 10 {…} Thread: Worker A Thread: Worker A Stream Subscriber Publisher
  11. 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 Data Access 11 {…} Subscriber Publisher Stream Thread: Worker A Thread: Worker B
  12. 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 Reactive with Spring Data 12 Spring Framework
 5 Project Reactor
 3 Spring Data
 Kay
  13. 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/ Reactor & Reactive Streams 13 Publisher<T> (0…n) Flux<T> (0…n) Mono<T> (0…1) Reactive Streams
  14. 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 Data & Reactor 14 <S extends T> Mono<S> insert(S entity); <S extends T> Mono<S> insert(Mono<S> entity); <S extends T> Flux<S> insert(Iterable<S> entities); <S extends T> Flux<S> insert(Publisher<S> entities); Mono<Boolean> exists(Mono<ID> id); Flux<T> findAll(); Mono<Long> count(); Mono<Void> delete(ID id); !!...
  15. 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 Data Reactive 15 interface Repo extends ReactiveCrudRepository<Person, String> { ! ! ! ! ! } Flux<Person> findByLastname(String lastname); Flux<Person> findByLastname(Mono<String> lastname); Flux<Person> customQuery(String lastname); @Query("{lastname : ?0}");
  16. 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/ Wake Up! It’s Demo Time
  17. 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/ Hang on just a little commercial break…
  18. 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/ 18 Learn More. Stay Connected. Twitter: twitter.com/springcentral YouTube: spring.io/video LinkedIn: spring.io/linkedin Google Plus: spring.io/gplus