Why does Spring not provide reactive (non-blocking) clients for relational databases?










5














I've used Vert.x toolkit for creating reactive applications with support for relational DBs like MySQL and Postgres. I know Spring provides reactive support for some NoSQL DBs like Cassandra and Mongo but are they willing to provide the same for relational DBs?










share|improve this question























  • Spring WebFlux and rxjava2-jdbc by Robert B Roeser link.medium.com/6ONWHPEsKR
    – uneq95
    Nov 11 at 4:20










  • stackoverflow.com/questions/42299455/…
    – uneq95
    Nov 11 at 4:21










  • baeldung.com/rxjava-jdbc
    – uneq95
    Nov 11 at 4:22










  • github.com/davidmoten/rxjava2-jdbc
    – uneq95
    Nov 11 at 4:23






  • 1




    Asynch JDBC is still being worked on: blogs.oracle.com/java/…
    – duffymo
    Dec 5 at 18:43
















5














I've used Vert.x toolkit for creating reactive applications with support for relational DBs like MySQL and Postgres. I know Spring provides reactive support for some NoSQL DBs like Cassandra and Mongo but are they willing to provide the same for relational DBs?










share|improve this question























  • Spring WebFlux and rxjava2-jdbc by Robert B Roeser link.medium.com/6ONWHPEsKR
    – uneq95
    Nov 11 at 4:20










  • stackoverflow.com/questions/42299455/…
    – uneq95
    Nov 11 at 4:21










  • baeldung.com/rxjava-jdbc
    – uneq95
    Nov 11 at 4:22










  • github.com/davidmoten/rxjava2-jdbc
    – uneq95
    Nov 11 at 4:23






  • 1




    Asynch JDBC is still being worked on: blogs.oracle.com/java/…
    – duffymo
    Dec 5 at 18:43














5












5








5


2





I've used Vert.x toolkit for creating reactive applications with support for relational DBs like MySQL and Postgres. I know Spring provides reactive support for some NoSQL DBs like Cassandra and Mongo but are they willing to provide the same for relational DBs?










share|improve this question















I've used Vert.x toolkit for creating reactive applications with support for relational DBs like MySQL and Postgres. I know Spring provides reactive support for some NoSQL DBs like Cassandra and Mongo but are they willing to provide the same for relational DBs?







java spring-data spring-webflux reactive r2dbc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 5 at 18:41









mp911de

8,95021953




8,95021953










asked Nov 11 at 1:10









Mis94

9151820




9151820











  • Spring WebFlux and rxjava2-jdbc by Robert B Roeser link.medium.com/6ONWHPEsKR
    – uneq95
    Nov 11 at 4:20










  • stackoverflow.com/questions/42299455/…
    – uneq95
    Nov 11 at 4:21










  • baeldung.com/rxjava-jdbc
    – uneq95
    Nov 11 at 4:22










  • github.com/davidmoten/rxjava2-jdbc
    – uneq95
    Nov 11 at 4:23






  • 1




    Asynch JDBC is still being worked on: blogs.oracle.com/java/…
    – duffymo
    Dec 5 at 18:43

















  • Spring WebFlux and rxjava2-jdbc by Robert B Roeser link.medium.com/6ONWHPEsKR
    – uneq95
    Nov 11 at 4:20










  • stackoverflow.com/questions/42299455/…
    – uneq95
    Nov 11 at 4:21










  • baeldung.com/rxjava-jdbc
    – uneq95
    Nov 11 at 4:22










  • github.com/davidmoten/rxjava2-jdbc
    – uneq95
    Nov 11 at 4:23






  • 1




    Asynch JDBC is still being worked on: blogs.oracle.com/java/…
    – duffymo
    Dec 5 at 18:43
















Spring WebFlux and rxjava2-jdbc by Robert B Roeser link.medium.com/6ONWHPEsKR
– uneq95
Nov 11 at 4:20




Spring WebFlux and rxjava2-jdbc by Robert B Roeser link.medium.com/6ONWHPEsKR
– uneq95
Nov 11 at 4:20












stackoverflow.com/questions/42299455/…
– uneq95
Nov 11 at 4:21




stackoverflow.com/questions/42299455/…
– uneq95
Nov 11 at 4:21












baeldung.com/rxjava-jdbc
– uneq95
Nov 11 at 4:22




baeldung.com/rxjava-jdbc
– uneq95
Nov 11 at 4:22












github.com/davidmoten/rxjava2-jdbc
– uneq95
Nov 11 at 4:23




github.com/davidmoten/rxjava2-jdbc
– uneq95
Nov 11 at 4:23




1




1




Asynch JDBC is still being worked on: blogs.oracle.com/java/…
– duffymo
Dec 5 at 18:43





Asynch JDBC is still being worked on: blogs.oracle.com/java/…
– duffymo
Dec 5 at 18:43













2 Answers
2






active

oldest

votes


















20














What's the idea behind the Spring Framework?



Spring Framework is a library to improve developer productivity, and so are Spring's portfolio projects such as Spring Data, Spring Security, Spring Cloud.



These projects build on top of existing APIs which are either standardized through a JSR or a JEP or on top of libraries that have proved to be useful and widely used. The Spring team does not build drivers for databases or other integrations, that's up to the database/driver vendors.



WebFlux compared to Vert.x



Spring WebFlux is an good example for a typical Spring module. It builds on top of existing non-blocking servers (Project Reactor via netty, Undertow, and Jetty). WebFlux provides a runtime container for non-blocking, reactive applications leveraging Spring components to assist in developing and running such applications.



Vert.x is an excellent example of an integrated environment that provides its own low-level implementations. Vert.x is heavily optimized and such an eco-system requires optimized integrations. Vert.x came up with own implementations for various databases and provides APIs that work well in a Vert.x context but these APIs are not JDBC.



Relational Database APIs



As M-Razavi already mentioned, Java uses JDBC to integrate with relational databases and JDBC is of a blocking nature – there's nothing sensible one could do about to mitigate the blocking nature of JDBC. Offloading JDBC calls to an Executor (typically Thread pool) is limited in its usefulness as the pool eventually saturates with requests). TL;DR, there's no API available on top of which we could provide a reactive relational database integration.



So what are the options?



M-Razavi already mentioned ADBA that is an initiative from Oracle to provide a standardized API for asynchronous database access in Java using futures. Everything in ADBA is still work in progress and the team behind ADBA is happy to get feedback. A bunch of Postgres folks is working on a Postgres ADBA driver that can be used for first experiments.



However, ADBA is a future goal and I expect that we don't see ADBA released with Java 12.



There are a couple of independent drivers such as Reactiverse's reactive-pg-client. These drivers come with a vendor-specific API and aren't really suited for a broader integration in Spring. We would need to provide additional layers to expose a common API, and new drivers couldn't be just plugged into your application so it works-out-of-the-box™. Having a standard API allows pluggability, so there's huge value in having a standard API.



R2DBC to the rescue?



Lacking a standard API and the non-availability of drivers, a team at Pivotal started to investigate on a reactive relational API that would be an ideal fit for reactive programming purposes. They came up with R2DBC which stands for Reactive Relational Database Connectivity. As of now, R2DBC is an incubator project to evaluate the feasibility and to start discussions whether driver vendors are interested at all in supporting reactive/non-blocking/asynchronous drivers.



As of now, there are three driver implementations:



  • PostgreSQL

  • H2

  • Microsoft SQL Server

R2DBC comes with an API specification (r2dbc-spi) and a client (r2dbc-client) that makes the SPI usable for applications. We started exploring on a Spring Data R2DBC integration that provides reactive APIs through a database client and by supporting reactive repositories.



R2DBC and its eco-system are still young and ask for experiments and feedback to collect use cases and to see whether a reactive relational database integration would make sense.



Right now, you can consume R2DBC through Spring Data and the following snippet shows DatabaseClient usage:



PostgresqlConnectionFactory connectionFactory = new PostgresqlConnectionFactory(…);

DatabaseClient databaseClient = DatabaseClient.create(connectionFactory);

Mono<Integer> count = databaseClient.execute()
.sql("INSERT INTO legoset (id, name, manual) VALUES($1, $2, $3)")
.bind("$1", 42055)
.bind("$2", "Description")
.bindNull("$3", Integer.class)
.fetch()
.rowsUpdated();

Flux<Map<String, Object>> rows = databaseClient.execute()
.sql("SELECT id, name, manual FROM legoset")
.fetch()
.all();





share|improve this answer




























    3














    Spring WebFlux is a great way to create a non-blocking REST application. One issue that you run into when start working with WebFlux is JDBC, because JDBC is blocking. New school databases like Cassandra or Couchbase have non-blocking drivers. In Couchbase’s case its driver uses RXJava. There is some effort going into creating asynchronous drivers for databases, as well as Oracle’s effort to create ADBA. Unfortunately, these are early days, and if you want to talk to a SQL database on the JVM you’re stuck with a blocking driver.

    Actually, Spring is not responsible for providing a none blocking driver for relational databases.






    share|improve this answer
















    • 2




      I don't know why this has been downvoted but i also have read that jdbc is blocking by its nature.
      – uneq95
      Nov 11 at 12:25










    • You are right, but I'm wondering as I mentioned other tools like Vert.x provide async clients for relational databases.
      – Mis94
      Nov 11 at 16:52






    • 1




      Most of the time these tools are putting lipstick on a blocking DB client (executing it in a managed thread pool that has the same size as the connection pool) and calling it reactive. see eg. stackoverflow.com/questions/50432154/…
      – Simon Baslé
      Dec 7 at 14:46










    • hmm...seems true, I didn't know this before.
      – Mis94
      Dec 8 at 19:58










    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244964%2fwhy-does-spring-not-provide-reactive-non-blocking-clients-for-relational-datab%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    20














    What's the idea behind the Spring Framework?



    Spring Framework is a library to improve developer productivity, and so are Spring's portfolio projects such as Spring Data, Spring Security, Spring Cloud.



    These projects build on top of existing APIs which are either standardized through a JSR or a JEP or on top of libraries that have proved to be useful and widely used. The Spring team does not build drivers for databases or other integrations, that's up to the database/driver vendors.



    WebFlux compared to Vert.x



    Spring WebFlux is an good example for a typical Spring module. It builds on top of existing non-blocking servers (Project Reactor via netty, Undertow, and Jetty). WebFlux provides a runtime container for non-blocking, reactive applications leveraging Spring components to assist in developing and running such applications.



    Vert.x is an excellent example of an integrated environment that provides its own low-level implementations. Vert.x is heavily optimized and such an eco-system requires optimized integrations. Vert.x came up with own implementations for various databases and provides APIs that work well in a Vert.x context but these APIs are not JDBC.



    Relational Database APIs



    As M-Razavi already mentioned, Java uses JDBC to integrate with relational databases and JDBC is of a blocking nature – there's nothing sensible one could do about to mitigate the blocking nature of JDBC. Offloading JDBC calls to an Executor (typically Thread pool) is limited in its usefulness as the pool eventually saturates with requests). TL;DR, there's no API available on top of which we could provide a reactive relational database integration.



    So what are the options?



    M-Razavi already mentioned ADBA that is an initiative from Oracle to provide a standardized API for asynchronous database access in Java using futures. Everything in ADBA is still work in progress and the team behind ADBA is happy to get feedback. A bunch of Postgres folks is working on a Postgres ADBA driver that can be used for first experiments.



    However, ADBA is a future goal and I expect that we don't see ADBA released with Java 12.



    There are a couple of independent drivers such as Reactiverse's reactive-pg-client. These drivers come with a vendor-specific API and aren't really suited for a broader integration in Spring. We would need to provide additional layers to expose a common API, and new drivers couldn't be just plugged into your application so it works-out-of-the-box™. Having a standard API allows pluggability, so there's huge value in having a standard API.



    R2DBC to the rescue?



    Lacking a standard API and the non-availability of drivers, a team at Pivotal started to investigate on a reactive relational API that would be an ideal fit for reactive programming purposes. They came up with R2DBC which stands for Reactive Relational Database Connectivity. As of now, R2DBC is an incubator project to evaluate the feasibility and to start discussions whether driver vendors are interested at all in supporting reactive/non-blocking/asynchronous drivers.



    As of now, there are three driver implementations:



    • PostgreSQL

    • H2

    • Microsoft SQL Server

    R2DBC comes with an API specification (r2dbc-spi) and a client (r2dbc-client) that makes the SPI usable for applications. We started exploring on a Spring Data R2DBC integration that provides reactive APIs through a database client and by supporting reactive repositories.



    R2DBC and its eco-system are still young and ask for experiments and feedback to collect use cases and to see whether a reactive relational database integration would make sense.



    Right now, you can consume R2DBC through Spring Data and the following snippet shows DatabaseClient usage:



    PostgresqlConnectionFactory connectionFactory = new PostgresqlConnectionFactory(…);

    DatabaseClient databaseClient = DatabaseClient.create(connectionFactory);

    Mono<Integer> count = databaseClient.execute()
    .sql("INSERT INTO legoset (id, name, manual) VALUES($1, $2, $3)")
    .bind("$1", 42055)
    .bind("$2", "Description")
    .bindNull("$3", Integer.class)
    .fetch()
    .rowsUpdated();

    Flux<Map<String, Object>> rows = databaseClient.execute()
    .sql("SELECT id, name, manual FROM legoset")
    .fetch()
    .all();





    share|improve this answer

























      20














      What's the idea behind the Spring Framework?



      Spring Framework is a library to improve developer productivity, and so are Spring's portfolio projects such as Spring Data, Spring Security, Spring Cloud.



      These projects build on top of existing APIs which are either standardized through a JSR or a JEP or on top of libraries that have proved to be useful and widely used. The Spring team does not build drivers for databases or other integrations, that's up to the database/driver vendors.



      WebFlux compared to Vert.x



      Spring WebFlux is an good example for a typical Spring module. It builds on top of existing non-blocking servers (Project Reactor via netty, Undertow, and Jetty). WebFlux provides a runtime container for non-blocking, reactive applications leveraging Spring components to assist in developing and running such applications.



      Vert.x is an excellent example of an integrated environment that provides its own low-level implementations. Vert.x is heavily optimized and such an eco-system requires optimized integrations. Vert.x came up with own implementations for various databases and provides APIs that work well in a Vert.x context but these APIs are not JDBC.



      Relational Database APIs



      As M-Razavi already mentioned, Java uses JDBC to integrate with relational databases and JDBC is of a blocking nature – there's nothing sensible one could do about to mitigate the blocking nature of JDBC. Offloading JDBC calls to an Executor (typically Thread pool) is limited in its usefulness as the pool eventually saturates with requests). TL;DR, there's no API available on top of which we could provide a reactive relational database integration.



      So what are the options?



      M-Razavi already mentioned ADBA that is an initiative from Oracle to provide a standardized API for asynchronous database access in Java using futures. Everything in ADBA is still work in progress and the team behind ADBA is happy to get feedback. A bunch of Postgres folks is working on a Postgres ADBA driver that can be used for first experiments.



      However, ADBA is a future goal and I expect that we don't see ADBA released with Java 12.



      There are a couple of independent drivers such as Reactiverse's reactive-pg-client. These drivers come with a vendor-specific API and aren't really suited for a broader integration in Spring. We would need to provide additional layers to expose a common API, and new drivers couldn't be just plugged into your application so it works-out-of-the-box™. Having a standard API allows pluggability, so there's huge value in having a standard API.



      R2DBC to the rescue?



      Lacking a standard API and the non-availability of drivers, a team at Pivotal started to investigate on a reactive relational API that would be an ideal fit for reactive programming purposes. They came up with R2DBC which stands for Reactive Relational Database Connectivity. As of now, R2DBC is an incubator project to evaluate the feasibility and to start discussions whether driver vendors are interested at all in supporting reactive/non-blocking/asynchronous drivers.



      As of now, there are three driver implementations:



      • PostgreSQL

      • H2

      • Microsoft SQL Server

      R2DBC comes with an API specification (r2dbc-spi) and a client (r2dbc-client) that makes the SPI usable for applications. We started exploring on a Spring Data R2DBC integration that provides reactive APIs through a database client and by supporting reactive repositories.



      R2DBC and its eco-system are still young and ask for experiments and feedback to collect use cases and to see whether a reactive relational database integration would make sense.



      Right now, you can consume R2DBC through Spring Data and the following snippet shows DatabaseClient usage:



      PostgresqlConnectionFactory connectionFactory = new PostgresqlConnectionFactory(…);

      DatabaseClient databaseClient = DatabaseClient.create(connectionFactory);

      Mono<Integer> count = databaseClient.execute()
      .sql("INSERT INTO legoset (id, name, manual) VALUES($1, $2, $3)")
      .bind("$1", 42055)
      .bind("$2", "Description")
      .bindNull("$3", Integer.class)
      .fetch()
      .rowsUpdated();

      Flux<Map<String, Object>> rows = databaseClient.execute()
      .sql("SELECT id, name, manual FROM legoset")
      .fetch()
      .all();





      share|improve this answer























        20












        20








        20






        What's the idea behind the Spring Framework?



        Spring Framework is a library to improve developer productivity, and so are Spring's portfolio projects such as Spring Data, Spring Security, Spring Cloud.



        These projects build on top of existing APIs which are either standardized through a JSR or a JEP or on top of libraries that have proved to be useful and widely used. The Spring team does not build drivers for databases or other integrations, that's up to the database/driver vendors.



        WebFlux compared to Vert.x



        Spring WebFlux is an good example for a typical Spring module. It builds on top of existing non-blocking servers (Project Reactor via netty, Undertow, and Jetty). WebFlux provides a runtime container for non-blocking, reactive applications leveraging Spring components to assist in developing and running such applications.



        Vert.x is an excellent example of an integrated environment that provides its own low-level implementations. Vert.x is heavily optimized and such an eco-system requires optimized integrations. Vert.x came up with own implementations for various databases and provides APIs that work well in a Vert.x context but these APIs are not JDBC.



        Relational Database APIs



        As M-Razavi already mentioned, Java uses JDBC to integrate with relational databases and JDBC is of a blocking nature – there's nothing sensible one could do about to mitigate the blocking nature of JDBC. Offloading JDBC calls to an Executor (typically Thread pool) is limited in its usefulness as the pool eventually saturates with requests). TL;DR, there's no API available on top of which we could provide a reactive relational database integration.



        So what are the options?



        M-Razavi already mentioned ADBA that is an initiative from Oracle to provide a standardized API for asynchronous database access in Java using futures. Everything in ADBA is still work in progress and the team behind ADBA is happy to get feedback. A bunch of Postgres folks is working on a Postgres ADBA driver that can be used for first experiments.



        However, ADBA is a future goal and I expect that we don't see ADBA released with Java 12.



        There are a couple of independent drivers such as Reactiverse's reactive-pg-client. These drivers come with a vendor-specific API and aren't really suited for a broader integration in Spring. We would need to provide additional layers to expose a common API, and new drivers couldn't be just plugged into your application so it works-out-of-the-box™. Having a standard API allows pluggability, so there's huge value in having a standard API.



        R2DBC to the rescue?



        Lacking a standard API and the non-availability of drivers, a team at Pivotal started to investigate on a reactive relational API that would be an ideal fit for reactive programming purposes. They came up with R2DBC which stands for Reactive Relational Database Connectivity. As of now, R2DBC is an incubator project to evaluate the feasibility and to start discussions whether driver vendors are interested at all in supporting reactive/non-blocking/asynchronous drivers.



        As of now, there are three driver implementations:



        • PostgreSQL

        • H2

        • Microsoft SQL Server

        R2DBC comes with an API specification (r2dbc-spi) and a client (r2dbc-client) that makes the SPI usable for applications. We started exploring on a Spring Data R2DBC integration that provides reactive APIs through a database client and by supporting reactive repositories.



        R2DBC and its eco-system are still young and ask for experiments and feedback to collect use cases and to see whether a reactive relational database integration would make sense.



        Right now, you can consume R2DBC through Spring Data and the following snippet shows DatabaseClient usage:



        PostgresqlConnectionFactory connectionFactory = new PostgresqlConnectionFactory(…);

        DatabaseClient databaseClient = DatabaseClient.create(connectionFactory);

        Mono<Integer> count = databaseClient.execute()
        .sql("INSERT INTO legoset (id, name, manual) VALUES($1, $2, $3)")
        .bind("$1", 42055)
        .bind("$2", "Description")
        .bindNull("$3", Integer.class)
        .fetch()
        .rowsUpdated();

        Flux<Map<String, Object>> rows = databaseClient.execute()
        .sql("SELECT id, name, manual FROM legoset")
        .fetch()
        .all();





        share|improve this answer












        What's the idea behind the Spring Framework?



        Spring Framework is a library to improve developer productivity, and so are Spring's portfolio projects such as Spring Data, Spring Security, Spring Cloud.



        These projects build on top of existing APIs which are either standardized through a JSR or a JEP or on top of libraries that have proved to be useful and widely used. The Spring team does not build drivers for databases or other integrations, that's up to the database/driver vendors.



        WebFlux compared to Vert.x



        Spring WebFlux is an good example for a typical Spring module. It builds on top of existing non-blocking servers (Project Reactor via netty, Undertow, and Jetty). WebFlux provides a runtime container for non-blocking, reactive applications leveraging Spring components to assist in developing and running such applications.



        Vert.x is an excellent example of an integrated environment that provides its own low-level implementations. Vert.x is heavily optimized and such an eco-system requires optimized integrations. Vert.x came up with own implementations for various databases and provides APIs that work well in a Vert.x context but these APIs are not JDBC.



        Relational Database APIs



        As M-Razavi already mentioned, Java uses JDBC to integrate with relational databases and JDBC is of a blocking nature – there's nothing sensible one could do about to mitigate the blocking nature of JDBC. Offloading JDBC calls to an Executor (typically Thread pool) is limited in its usefulness as the pool eventually saturates with requests). TL;DR, there's no API available on top of which we could provide a reactive relational database integration.



        So what are the options?



        M-Razavi already mentioned ADBA that is an initiative from Oracle to provide a standardized API for asynchronous database access in Java using futures. Everything in ADBA is still work in progress and the team behind ADBA is happy to get feedback. A bunch of Postgres folks is working on a Postgres ADBA driver that can be used for first experiments.



        However, ADBA is a future goal and I expect that we don't see ADBA released with Java 12.



        There are a couple of independent drivers such as Reactiverse's reactive-pg-client. These drivers come with a vendor-specific API and aren't really suited for a broader integration in Spring. We would need to provide additional layers to expose a common API, and new drivers couldn't be just plugged into your application so it works-out-of-the-box™. Having a standard API allows pluggability, so there's huge value in having a standard API.



        R2DBC to the rescue?



        Lacking a standard API and the non-availability of drivers, a team at Pivotal started to investigate on a reactive relational API that would be an ideal fit for reactive programming purposes. They came up with R2DBC which stands for Reactive Relational Database Connectivity. As of now, R2DBC is an incubator project to evaluate the feasibility and to start discussions whether driver vendors are interested at all in supporting reactive/non-blocking/asynchronous drivers.



        As of now, there are three driver implementations:



        • PostgreSQL

        • H2

        • Microsoft SQL Server

        R2DBC comes with an API specification (r2dbc-spi) and a client (r2dbc-client) that makes the SPI usable for applications. We started exploring on a Spring Data R2DBC integration that provides reactive APIs through a database client and by supporting reactive repositories.



        R2DBC and its eco-system are still young and ask for experiments and feedback to collect use cases and to see whether a reactive relational database integration would make sense.



        Right now, you can consume R2DBC through Spring Data and the following snippet shows DatabaseClient usage:



        PostgresqlConnectionFactory connectionFactory = new PostgresqlConnectionFactory(…);

        DatabaseClient databaseClient = DatabaseClient.create(connectionFactory);

        Mono<Integer> count = databaseClient.execute()
        .sql("INSERT INTO legoset (id, name, manual) VALUES($1, $2, $3)")
        .bind("$1", 42055)
        .bind("$2", "Description")
        .bindNull("$3", Integer.class)
        .fetch()
        .rowsUpdated();

        Flux<Map<String, Object>> rows = databaseClient.execute()
        .sql("SELECT id, name, manual FROM legoset")
        .fetch()
        .all();






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 5 at 18:40









        mp911de

        8,95021953




        8,95021953























            3














            Spring WebFlux is a great way to create a non-blocking REST application. One issue that you run into when start working with WebFlux is JDBC, because JDBC is blocking. New school databases like Cassandra or Couchbase have non-blocking drivers. In Couchbase’s case its driver uses RXJava. There is some effort going into creating asynchronous drivers for databases, as well as Oracle’s effort to create ADBA. Unfortunately, these are early days, and if you want to talk to a SQL database on the JVM you’re stuck with a blocking driver.

            Actually, Spring is not responsible for providing a none blocking driver for relational databases.






            share|improve this answer
















            • 2




              I don't know why this has been downvoted but i also have read that jdbc is blocking by its nature.
              – uneq95
              Nov 11 at 12:25










            • You are right, but I'm wondering as I mentioned other tools like Vert.x provide async clients for relational databases.
              – Mis94
              Nov 11 at 16:52






            • 1




              Most of the time these tools are putting lipstick on a blocking DB client (executing it in a managed thread pool that has the same size as the connection pool) and calling it reactive. see eg. stackoverflow.com/questions/50432154/…
              – Simon Baslé
              Dec 7 at 14:46










            • hmm...seems true, I didn't know this before.
              – Mis94
              Dec 8 at 19:58















            3














            Spring WebFlux is a great way to create a non-blocking REST application. One issue that you run into when start working with WebFlux is JDBC, because JDBC is blocking. New school databases like Cassandra or Couchbase have non-blocking drivers. In Couchbase’s case its driver uses RXJava. There is some effort going into creating asynchronous drivers for databases, as well as Oracle’s effort to create ADBA. Unfortunately, these are early days, and if you want to talk to a SQL database on the JVM you’re stuck with a blocking driver.

            Actually, Spring is not responsible for providing a none blocking driver for relational databases.






            share|improve this answer
















            • 2




              I don't know why this has been downvoted but i also have read that jdbc is blocking by its nature.
              – uneq95
              Nov 11 at 12:25










            • You are right, but I'm wondering as I mentioned other tools like Vert.x provide async clients for relational databases.
              – Mis94
              Nov 11 at 16:52






            • 1




              Most of the time these tools are putting lipstick on a blocking DB client (executing it in a managed thread pool that has the same size as the connection pool) and calling it reactive. see eg. stackoverflow.com/questions/50432154/…
              – Simon Baslé
              Dec 7 at 14:46










            • hmm...seems true, I didn't know this before.
              – Mis94
              Dec 8 at 19:58













            3












            3








            3






            Spring WebFlux is a great way to create a non-blocking REST application. One issue that you run into when start working with WebFlux is JDBC, because JDBC is blocking. New school databases like Cassandra or Couchbase have non-blocking drivers. In Couchbase’s case its driver uses RXJava. There is some effort going into creating asynchronous drivers for databases, as well as Oracle’s effort to create ADBA. Unfortunately, these are early days, and if you want to talk to a SQL database on the JVM you’re stuck with a blocking driver.

            Actually, Spring is not responsible for providing a none blocking driver for relational databases.






            share|improve this answer












            Spring WebFlux is a great way to create a non-blocking REST application. One issue that you run into when start working with WebFlux is JDBC, because JDBC is blocking. New school databases like Cassandra or Couchbase have non-blocking drivers. In Couchbase’s case its driver uses RXJava. There is some effort going into creating asynchronous drivers for databases, as well as Oracle’s effort to create ADBA. Unfortunately, these are early days, and if you want to talk to a SQL database on the JVM you’re stuck with a blocking driver.

            Actually, Spring is not responsible for providing a none blocking driver for relational databases.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 11 at 7:14









            M-Razavi

            1,37311731




            1,37311731







            • 2




              I don't know why this has been downvoted but i also have read that jdbc is blocking by its nature.
              – uneq95
              Nov 11 at 12:25










            • You are right, but I'm wondering as I mentioned other tools like Vert.x provide async clients for relational databases.
              – Mis94
              Nov 11 at 16:52






            • 1




              Most of the time these tools are putting lipstick on a blocking DB client (executing it in a managed thread pool that has the same size as the connection pool) and calling it reactive. see eg. stackoverflow.com/questions/50432154/…
              – Simon Baslé
              Dec 7 at 14:46










            • hmm...seems true, I didn't know this before.
              – Mis94
              Dec 8 at 19:58












            • 2




              I don't know why this has been downvoted but i also have read that jdbc is blocking by its nature.
              – uneq95
              Nov 11 at 12:25










            • You are right, but I'm wondering as I mentioned other tools like Vert.x provide async clients for relational databases.
              – Mis94
              Nov 11 at 16:52






            • 1




              Most of the time these tools are putting lipstick on a blocking DB client (executing it in a managed thread pool that has the same size as the connection pool) and calling it reactive. see eg. stackoverflow.com/questions/50432154/…
              – Simon Baslé
              Dec 7 at 14:46










            • hmm...seems true, I didn't know this before.
              – Mis94
              Dec 8 at 19:58







            2




            2




            I don't know why this has been downvoted but i also have read that jdbc is blocking by its nature.
            – uneq95
            Nov 11 at 12:25




            I don't know why this has been downvoted but i also have read that jdbc is blocking by its nature.
            – uneq95
            Nov 11 at 12:25












            You are right, but I'm wondering as I mentioned other tools like Vert.x provide async clients for relational databases.
            – Mis94
            Nov 11 at 16:52




            You are right, but I'm wondering as I mentioned other tools like Vert.x provide async clients for relational databases.
            – Mis94
            Nov 11 at 16:52




            1




            1




            Most of the time these tools are putting lipstick on a blocking DB client (executing it in a managed thread pool that has the same size as the connection pool) and calling it reactive. see eg. stackoverflow.com/questions/50432154/…
            – Simon Baslé
            Dec 7 at 14:46




            Most of the time these tools are putting lipstick on a blocking DB client (executing it in a managed thread pool that has the same size as the connection pool) and calling it reactive. see eg. stackoverflow.com/questions/50432154/…
            – Simon Baslé
            Dec 7 at 14:46












            hmm...seems true, I didn't know this before.
            – Mis94
            Dec 8 at 19:58




            hmm...seems true, I didn't know this before.
            – Mis94
            Dec 8 at 19:58

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid …


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid …


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244964%2fwhy-does-spring-not-provide-reactive-non-blocking-clients-for-relational-datab%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            政党

            天津地下鉄3号線