Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Reactive Data Access with Spring Data

SpringOne Platform 2017
Christoph Strobl, Pivotal; Mark Paluch, Pivotal

How do you improve efficiency, reduce latency and memory footprint of your data access? Reactive Streams on top of a functional-reactive programming model are key. Both are two predominant concepts in reactive systems, that completely change how we approach data access in applications today. Reactive data access improves resource usage efficiency and eliminates several constraints of today’s imperative approaches.

This talk covers non-blocking data access using Spring Data for NoSQl data stores and Project Reactor. You will learn how to integrate Spring Data repositories in an end-to-end reactive web application. 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.

  • Login to see the comments

Reactive Data Access with Spring Data

  1. 1. Reactive Spring Data Mark Paluch @mp911de Christoph Strobl @stroblchristoph 1
  2. 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/ Spring Data Modules 3 JPA
  3. 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/ Reactive Spring Data Modules 4 JPA
  4. 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/ 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/ image:FireattheBamberFamilyHome(FALv.1.3License)
  5. 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/ 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/
  6. 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/ 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/ image:FireattheBamberFamilyHome(FALv.1.3License)
  7. 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/ 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/ image:FireattheBamberFamilyHome(FALv.1.3License)
  8. 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/ 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/ image:FireattheBamberFamilyHome(FALv.1.3License)
  9. 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/ 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/ image:FireattheBamberFamilyHome(FALv.1.3License)
  10. 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 • Asynchronous • Non Blocking • Event Driven • Data as stream 12
  11. 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/ Publisher 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/ image:FireattheBamberFamilyHome(FALv.1.3License) Subscriber Backpressure Stream / Flow Subscribe
  12. 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/ What it takes… Project Reactor 3.1 Spring Framework 5.0 Spring Data 2.0 A reactive (asynchronous, ideally non-blocking) driver Optional: Spring Boot 2.0 (Milestone) 14
  13. 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/ What about JDBC/JPA? JDBC is a blocking API JPA is a blocking API Sorry, no reactive JPA support 15
  14. 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/ Reactive Spring Data Reactive Template API Reactive Repository support Reduced feature set 16
  15. 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/ Imperative Template API 17 <T> T insert(T objectToSave) void insertAll(Collection<…> objects) <T> List<T> find(Query query, Class<T> type)
  16. 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/ Reactive Template API 18 <T> Mono<T> insert(T objectToSave) <T> Mono<T> insert(Mono<T> objects) <T> Flux<T> find(Query query, Class<T> type)
  17. 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/ Reactive Repository API 19 interface ReactivePersonRepository extends ReactiveCrudRepository<Person, String> { Flux<Person> findByLastname(String lastname); @Query("{ 'firstname': ?0 }") Mono<Person> customQuery(String firstname); Flux<Person> findByLastname(Mono<String> lastname); }
  18. 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/ Reactive Repository API 20 interface ReactivePersonRepository extends ReactiveCrudRepository<Person, String> { Flux<Person> findByLastname(String lastname); @Query("{ 'firstname': ?0 }") Mono<Person> customQuery(String firstname); Flux<Person> findByLastname(Mono<String> lastname); }
  19. 19. 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 Repository API 21 interface ReactivePersonRepository extends ReactiveCrudRepository<Person, String> { Flux<Person> findByLastname(String lastname); @Query("{ 'firstname': ?0 }") Mono<Person> customQuery(String firstname); Flux<Person> findByLastname(Mono<String> lastname); }
  20. 20. 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 Repository API 22 interface ReactivePersonRepository extends ReactiveCrudRepository<Person, String> { Flux<Person> findByLastname(String lastname); @Query("{ 'firstname': ?0 }") Mono<Person> customQuery(String firstname); Flux<Person> findByLastname(Mono<String> lastname); }
  21. 21. 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 Repository API 23 interface ReactivePersonRepository extends RxJava2CrudRepository<Person, String> { Flowable<Person> findByLastname(String lastname); @Query("{ 'firstname': ?0 }") Maybe<Person> customQuery(String firstname); Single<Person> findByLastname(Mono<String> lastname); }
  22. 22. 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 Repository API 24 interface ReactivePersonRepository extends RxJava2CrudRepository<Person, String> { Flowable<Person> findByLastname(String lastname); @Query("{ 'firstname': ?0 }") Maybe<Person> customQuery(String firstname); Single<Person> findByLastname(Mono<String> lastname); }
  23. 23. Learn More. Stay Connected. Spring Data Examples – Repository @ Github WebFlux Example – Repository @ Github 25 #springone@s1p
  24. 24. Disclaimer
  25. 25. 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/ Safe Harbor Statement The following is intended to outline the general direction of Pivotal's offerings. It is intended for information purposes only and may not be incorporated into any contract. Any information regarding pre-release of Pivotal offerings, future updates or other planned modifications is subject to ongoing evaluation by Pivotal and is subject to change. This information is provided without warranty or any kind, express or implied, and is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions regarding Pivotal's offerings. These purchasing decisions should only be based on features currently available. The development, release, and timing of any features or functionality described for Pivotal's offerings in this presentation remain at the sole discretion of Pivotal. Pivotal has no obligation to update forward looking information in this presentation. 27

×