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

Going Reactive with Spring Data (JUG Berlin-Brandenburg)

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

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

    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/
    Synchronous Data Access
    3
    {…}
    Thread: MAIN

    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/
    Synchronous Data Access II
    4
    {…}
    Thread: MAIN
    Batching

    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/
    Asynchronous Data Access
    5
    {…}
    Dispatcher
    Thread: MAIN
    Thread: Worker A
    Thread: Worker B
    Thread: Worker C

    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/
    Asynchronous Data Access II
    6
    {…}
    Dispatcher
    Thread: MAIN
    Thread: Worker A
    Thread: Worker B
    Thread: Worker C
    Scaling

    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/
    Reactive Data Access
    7
    {…}
    Subscriber Publisher
    Stream

    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
    Iterator.next()
    Future.get()
    Subscriber.onNext(t)

    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/
    Reactive Data Access
    9
    {…}
    Stream
    Thread: MAIN
    Subscriber Publisher

    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/
    Reactive Data Access
    10
    {…}
    Thread: Worker A
    Thread: Worker A
    Stream
    Subscriber Publisher

    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/
    Reactive Data Access
    11
    {…}
    Subscriber Publisher
    Stream
    Thread: Worker A
    Thread: Worker B

    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/
    Going Reactive with Spring Data
    12
    Spring Framework

    5
    Project Reactor

    3
    Spring Data

    Kay

    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/
    Reactor & Reactive Streams
    13
    Publisher (0…n)
    Flux (0…n) Mono (0…1)
    Reactive Streams

    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/
    Spring Data & Reactor
    14
    Mono insert(S entity);
    Mono insert(Mono entity);
    Flux insert(Iterable entities);
    Flux insert(Publisher entities);
    Mono exists(Mono id);
    Flux findAll();
    Mono count();
    Mono delete(ID id);
    !!...

    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/
    Spring Data Reactive
    15
    interface Repo extends ReactiveCrudRepository {
    !
    !
    !
    !
    !
    }
    Flux findByLastname(String lastname);
    Flux findByLastname(Mono lastname);
    Flux customQuery(String lastname);
    @Query("{lastname : ?0}");

    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/
    Wake Up!
    It’s Demo Time

    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/
    Hang on just a little
    commercial break…

    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/
    18
    Learn More. Stay Connected.
    Twitter: twitter.com/springcentral
    YouTube: spring.io/video
    LinkedIn: spring.io/linkedin
    Google Plus: spring.io/gplus

    View Slide