$30 off During Our Annual Pro Sale. View Details »

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. @mp911de
    #DevoxxPL
    Platinum Sponsor:
    Reactive meets
    Data Access
    Mark Paluch
    Pivotal

    View Slide

  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
    2
    Request Data access
    Remote data
    service
    I/O Wait
    !
    This one is
    waiting

    View Slide

  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/
    Accessing Data today
    3
    Request Data access
    Remote data
    service
    Multiple
    calls
    Bulk fetch
    !

    View Slide

  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/
    Asynchronous data access
    4
    Request Data access
    Requires
    synchronization
    Still waiting, eh?
    "
    #
    $

    View Slide

  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/
    5

    View Slide

  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/
    6

    View Slide

  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/
    7

    View Slide

  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

    View Slide

  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/
    9

    View Slide

  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/
    Conditional asynchronous access
    10
    % Future Hell

    View Slide

  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/
    ! Keep resources busy
    ! Connection contention
    ! Usually synchronous/blocking
    ! Multiple requests
    ! Asynchronous isn’t always a good answer
    11
    Todays’ Data Access

    View Slide

  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/
    Scaling
    12
    &
    &
    &
    & & & &
    & & & &
    & & & &
    & & & &

    View Slide

  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/
    Change the level of abstraction
    13
    Data as Stream
    Reactive execution model

    View Slide

  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/
    14
    List
    Iterator
    Future
    Future>
    .get()
    for-each .hasNext()
    Request thread pulls

    View Slide

  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/
    15
    Publisher
    I/O thread
    push

    View Slide

  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/
    16
    Publisher
    Stream
    (Publisher)
    Subscriber
    Demand
    Data

    View Slide

  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/
    ! Immutable
    ! Push-Stream
    ! Iterator, java.stream.Stream are Pull-Streams
    ! Demand-Aware (Backpressure)
    17
    Reactive Streams

    View Slide

  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/
    Going reactive with Spring Data
    18
    Project Reactor 3.0 Spring Data 2.0
    Spring Framework 5.0

    View Slide

  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/
    19
    Mono
    Flux
    0..1..Error
    0..N..Error

    View Slide

  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 Template API
    ! Reactive Repository support
    ! Supported data stores (Reactive Streams)
    ! MongoDB
    ! Apache Cassandra
    ! Redis
    ! Couchbase (RxJava 1 driver)
    20
    Spring Data

    View Slide

  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/
    21
    Reactive Template API
    Mono insert(T objectToSave)
    Mono insert(Mono objectToSave)

    View Slide

  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/
    22
    Let’s code…

    View Slide

  23. 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

    View Slide

  24. 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

    View Slide

  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/
    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

    View Slide