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

Reactive meets Data Access

Reactive meets Data Access

Slides to the talk I gave at Devoxx PL 2017.

Links:
* Spring Data Examples: https://github.com/spring-projects/spring-data-examples
* Spring Data wiki: https://github.com/spring-projects/spring-data-commons/wiki
* Spring Project release calendar: https://spring-calendar.cfapps.io/
* Code: http://mp911.de/reactive-meets-data-access-code

Mark Paluch

June 21, 2017
Tweet

More Decks by Mark Paluch

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/ Accessing Data today 2 Request Data access Remote data service I/O Wait ! This one is waiting
  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/ Accessing Data today 3 Request Data access Remote data service Multiple calls Bulk fetch !
  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/ Asynchronous data access 4 Request Data access Requires synchronization Still waiting, eh? " # $
  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/ 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/ 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/ 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/ 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/ 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/ Conditional asynchronous access 10 % Future Hell
  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/ ! Keep resources busy ! Connection contention ! Usually synchronous/blocking ! Multiple requests ! Asynchronous isn’t always a good answer 11 Todays’ Data Access
  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/ Scaling 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/ Change the level of abstraction 13 Data as Stream Reactive execution model
  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/ 14 List<T> Iterator<T> Future<T> Future<List<T>> .get() for-each .hasNext() Request thread pulls
  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/ 15 Publisher<T> I/O thread push
  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/ 16 Publisher Stream (Publisher) Subscriber Demand Data
  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/ ! Immutable ! Push-Stream ! Iterator, java.stream.Stream are Pull-Streams ! Demand-Aware (Backpressure) 17 Reactive Streams
  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/ Going reactive with Spring Data 18 Project Reactor 3.0 Spring Data 2.0 Spring Framework 5.0
  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/ 19 Mono<T> Flux<T> 0..1..Error 0..N..Error
  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 Template API ! Reactive Repository support ! Supported data stores (Reactive Streams) ! MongoDB ! Apache Cassandra ! Redis ! Couchbase (RxJava 1 driver) 20 Spring Data
  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/ 21 Reactive Template API <T> Mono<T> insert(T objectToSave) <T> Mono<T> insert(Mono<T> objectToSave)
  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/ 22 Let’s code…
  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/ 23 Spring Data 2.0 Java 8 API Ready for Java 9 Fluent MongoDB API MongoDB Collation support Elasticsearch 5.4 Cassandra Lightweight transactions Cassandra Query & Update objects Composable repositories Kotlin extensions On the way to non-null API Consistent CRUD repository method names MongoDB Document API New Redis Cache Cassandra module merge
  23. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Feedback Welcome
  24. 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/ Resources ! Spring Data Examples – Repository @ Github ! Spring Data wiki (Release trains, planning) – Wiki ! Spring projects release calendar – Google Calendar ! Slides – Speakerdeck (mp911.de/reactive-meets-data-access) ! Code – GitHub (mp911.de/reactive-meets-data-access-code) ! Chat with us on Gitter! 25 @mp911de