Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for R2DBC #19988

Closed
jabrena opened this issue Jan 30, 2020 · 12 comments
Closed

Add support for R2DBC #19988

jabrena opened this issue Jan 30, 2020 · 12 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@jabrena
Copy link

jabrena commented Jan 30, 2020

Good afternoon,

I would like to know if exist any plan to provide a R2DBC starter that is shipped by Spring Boot itself. Currently, if a project requires the dependency R2DBC, it appears as Experimental in
https://start.spring.io/

Does exist any plan to change the status?

Many thanks in advance

Juan Antonio

@mp911de

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 30, 2020
@snicoll
Copy link
Member

snicoll commented Jan 31, 2020

As far as I know, r2dbc is scheduled to be integrated to the Spring Data release train with Neumann (next major release). When that's the case, it will no longer be experimental and we can take it from there.

Going forward, please ask questions on ou Gitter channel or StackOverflow.

@snicoll snicoll closed this as completed Jan 31, 2020
@snicoll snicoll added for: stackoverflow A question that's better suited to stackoverflow.com and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 31, 2020
@snicoll
Copy link
Member

snicoll commented Jan 31, 2020

Looking at the issue tracker, we don't have an issue to track the integration of R2DBC here so we can just as well reuse this issue. I'll update the title to make that clear.

@snicoll snicoll reopened this Jan 31, 2020
@snicoll snicoll added type: enhancement A general enhancement and removed for: stackoverflow A question that's better suited to stackoverflow.com labels Jan 31, 2020
@snicoll snicoll added this to the 2.x milestone Jan 31, 2020
@snicoll snicoll changed the title Provide a R2DBC starter that is shipped by Spring Boot itself Add support for R2DBC Jan 31, 2020
@snicoll snicoll modified the milestones: 2.x, 2.3.x Jan 31, 2020
@snicoll
Copy link
Member

snicoll commented Jan 31, 2020

We've discussed this one a bit today and we're going to do our best to implement this for 2.3. We're going to use a separate namespace, with support for Flyway and Liquibase only, creating a "local" DataSource for the purpose of the migration.

We should also upgrade @AutoConfigureTestDatabase to swap the ConnectionFactory if possible.

The work that has been done in https://github.com/spring-projects-experimental/spring-boot-r2dbc should help us significantly.

@snicoll snicoll self-assigned this Jan 31, 2020
@snicoll
Copy link
Member

snicoll commented Feb 4, 2020

We've been discussing how database initialization should work and the relationship with spring.datasource. We think that the two should be completely separated and yet some of the datasource auto-config should be aware of the fact that a fallback was applied on the R2DBC side of things.

In short:

  • The schema.sql and data.sql support needs some improvements so we're not keen to move that model over to R2DBC
  • There is an opportunity to improve the flyway and liquibase auto-coniguration to detect if a DataSourceProvider interface is present. R2DBC could expose such an interface when it configures a ConnectionFactory. This would make the datasource initialization support transparent
  • If a DataSourceProvider bean is present, the embedded fallback that DataSourceAutoConfiguration applies should back-off The net effect is that, when using R2DBC, no DataSource bean is exposed at all (unless a uri is configured explicitly).

@snicoll
Copy link
Member

snicoll commented Feb 7, 2020

I've made quite some good progress on the experimental project. ConnectionFactoryBuilder and R2dbcProperties are in a state that would fit with what we have in mind. data/schema support has been therefore removed. This is available on master as I'd like to check for potential issues.

I've also started to spike on the idea to translate a ConnectionFactoryOptions to a jdbc url automatically. Need some more testing and a change here to introduce the DatasourceProvider contract.

@snicoll
Copy link
Member

snicoll commented Feb 20, 2020

@mp911de
Copy link
Member

mp911de commented Feb 20, 2020

@snicoll
Copy link
Member

snicoll commented Feb 20, 2020

Thanks @mp911de, this helped.

snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
Co-authored-by: Oliver Drotbohm <odrotbohm@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
Co-authored-by: Tadaya Tsuyukubo <tadaya@ttddyy.net>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
Co-authored-by: Oliver Drotbohm <odrotbohm@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
Co-authored-by: Tadaya Tsuyukubo <tadaya@ttddyy.net>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
Co-authored-by: Oliver Drotbohm <odrotbohm@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 21, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
Co-authored-by: Tadaya Tsuyukubo <tadaya@ttddyy.net>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 24, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 24, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
Co-authored-by: Oliver Drotbohm <odrotbohm@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 24, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 24, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 24, 2020
See spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
Co-authored-by: Tadaya Tsuyukubo <tadaya@ttddyy.net>
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 24, 2020
snicoll added a commit to snicoll/spring-boot that referenced this issue Feb 24, 2020
Closes spring-projectsgh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit that referenced this issue Feb 25, 2020
This commit adds auto-configuration for R2DBC. If R2DBC is on the
classpath, a `ConnectionFactory` is created similarly to the algorithm
used to create a `DataSource`.

If an url is specified, it is used to determine the R2DBC driver and
database location. If not, an embedded database is started (with only
support of H2 via r2dbc-h2). If none of those succeed, an exception is
thrown that is handled by a dedicated FailureAnalyzer.

To clearly separate reactive from imperative access, a `DataSource` is
not auto-configured if a `ConnectionFactory` is present. This makes sure
that any auto-configuration that relies on the presence of a
`DataSource` backs off.

There is no dedicated database initialization at the moment but it is
possible to configure flyway or liquibase to create a local `DataSource`
for the duration of the migration. Alternatively, if Spring Data R2DBC
is on the classpath, a `ResourceDatabasePopulator` bean can be defined
with the scripts to execute on startup.

See gh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit that referenced this issue Feb 25, 2020
This commit adds auto-configuration support for Spring Data R2DBC. If a
`ConnectionFactory` and Spring Data are available, scanning of reactive
repositories is enabled.

This commit also adds a starter to bring R2DBC and the necessary Spring
Data libraries.

See gh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
Co-authored-by: Oliver Drotbohm <odrotbohm@pivotal.io>
snicoll added a commit that referenced this issue Feb 25, 2020
This commit adds a test slice for Spring Data R2DBC. When
`DataR2dbcTest` is added on a test, only Spring Data R2DBC repositories
and the infrastructure that they need is auto-configured.

Contrary to the JDBC counterpart, the `ConnectionFactory` is not swapped
by an embedded database.

See gh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit that referenced this issue Feb 25, 2020
This commit adds an health indicator for R2DBC. If a validation query is
provided, it is used to validate the state of the database. If not, a
check of the connection is issued.

See gh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
snicoll added a commit that referenced this issue Feb 25, 2020
This commit adds metrics support for `ConnectionPool` beans.

See gh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
Co-authored-by: Tadaya Tsuyukubo <tadaya@ttddyy.net>
snicoll added a commit that referenced this issue Feb 25, 2020
See gh-19988

Co-authored-by: Mark Paluch <mpaluch@pivotal.io>
@snicoll snicoll modified the milestones: 2.3.x, 2.3.0.M3 Feb 25, 2020
@abhi2495
Copy link

abhi2495 commented Jul 15, 2020

@snicoll What is the spring boot dependency to be used for using the r2dbc ?

Is this the one or any spring boot starter dependency also present?

org.springframework.data spring-data-r2dbc 1.1.1.RELEASE

@wilkinsona
Copy link
Member

wilkinsona commented Jul 15, 2020

@abhi2495 There's a list of starters in the reference documentation where you'll find spring-boot-starter-data-r2dbc which is the "starter for using Spring Data R2DBC". If you want to use R2DBC without Spring Data, then there's no starter and you should add the R2DBC dependencies directly.

@abhi2495
Copy link

Thanks @wilkinsona . Thing is , the only spring-boot-starter-data-r2dbc artifact that I could see listed in Maven repository belonged to the group org.springframework.boot.experimental. That's why I wanted to know if there is a starter artifact from group org.springframework.boot

@scottfrederick
Copy link
Contributor

@abhi2495 org.springframework.boot:spring-boot-starter-data-r2dbc has been in Maven Central and the Spring Release repository since version 2.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

7 participants