Reactive Data Access with Spring Data
Transcript of Reactive Data Access with Spring Data
![Page 1: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/1.jpg)
Reactive Spring Data
Mark Paluch @mp911de
Christoph Strobl @stroblchristoph
1
![Page 2: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/2.jpg)
![Page 3: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/3.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/by -nc /3 .0 /
Spring Data Modules
3
JPA
![Page 4: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/4.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/by -nc /3 .0 /
Reactive Spring Data Modules
4
JPA
![Page 5: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/5.jpg)
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/
ima
ge
: F
ire
at
the
Ba
mb
er
Fa
mily
Ho
me
(F
AL
v.1
.3 L
ice
nse
)
![Page 6: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/6.jpg)
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/
![Page 7: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/7.jpg)
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/
ima
ge
: F
ire
at
the
Ba
mb
er
Fa
mily
Ho
me
(F
AL
v.1
.3 L
ice
nse
)
![Page 8: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/8.jpg)
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/
ima
ge
: F
ire
at
the
Ba
mb
er
Fa
mily
Ho
me
(F
AL
v.1
.3 L
ice
nse
)
![Page 9: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/9.jpg)
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/
ima
ge
: F
ire
at
the
Ba
mb
er
Fa
mily
Ho
me
(F
AL
v.1
.3 L
ice
nse
)
![Page 10: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/10.jpg)
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/
ima
ge
: F
ire
at
the
Ba
mb
er
Fa
mily
Ho
me
(F
AL
v.1
.3 L
ice
nse
)
![Page 11: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/11.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/by -nc /3 .0 /
Reactive data access
• Asynchronous
• Non Blocking
• Event Driven
• Data as stream
12
![Page 12: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/12.jpg)
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/
ima
ge
: F
ire
at
the
Ba
mb
er
Fa
mily
Ho
me
(F
AL
v.1
.3 L
ice
nse
)
Subscriber
Backpressure
Stream / Flow
Subscribe
![Page 13: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/13.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/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
![Page 14: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/14.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/by -nc /3 .0 /
What about JDBC/JPA?
JDBC is a blocking API
JPA is a blocking API
Sorry, no reactive JPA support
15
![Page 15: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/15.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/by -nc /3 .0 /
Reactive Spring Data
Reactive Template API
Reactive Repository support
Reduced feature set
16
![Page 16: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/16.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/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)
![Page 17: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/17.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/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)
![Page 18: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/18.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/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);
}
![Page 19: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/19.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/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);
}
![Page 20: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/20.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/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);
}
![Page 21: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/21.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/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);
}
![Page 22: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/22.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/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);
}
![Page 23: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/23.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/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);
}
![Page 24: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/24.jpg)
Learn More. Stay Connected.
Spring Data Examples – Repository @ Github
WebFlux Example – Repository @ Github
25
#springone@s1p
![Page 25: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/25.jpg)
Disclaimer
![Page 26: Reactive Data Access with Spring Data](https://reader033.fdocuments.us/reader033/viewer/2022052606/5a6d306d7f8b9abd418b58d9/html5/thumbnails/26.jpg)
Unless o therwise ind ica ted, these s l ides a re © 2013 -2017 P ivo ta l So f tware , Inc . and l i censed under a Crea t ive Commons
At t r ibu t ion -NonCommerc ia l l i cense : h t tp : / / c rea t ivecommons.org/ l i censes/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