iabughosh
iabughosh

Reputation: 551

Quarkus reactive client MySql client is not inserting records

I am doing a poc for Quarks-Mysql reactive client using Quarkus 1.1.0.Final. The code is like the below :

public void put() {

        mysqlPool
            .begin(ar ->{
                if(ar.succeeded()) {
                    Transaction tx = ar.result();
                    tx.preparedQuery(
                        "insert into Book(categoryType, description, isbn, name, price, totalBuyers) values(?, ?, ?, ?, ?, ?)",
                        Tuple.of(1, "Fresh one", "ISBN-0", "Fresh", 100.0, 0),
                        qr -> {
                            if(qr.succeeded()) {
                                tx.commit(txr -> {
                                    if(txr.succeeded()) {
                                        System.out.println("Successful !!!");//Is not printing
                                    } else {
                                        System.err.println("Failed !!!");//Is not printing
                                    }
                                });
                            }
                            tx.close();
                        });
                }
            }); 
    }

After calling tx.commit, no async result is coming back (either success or failure) and no new record is inserted into database. inspire of that the auto id is getting incremented after each call. I am checking it using this.

My application.properties is :

quarkus.datasource.url = vertx-reactive:mysql://localhost:3306/ebs_book
quarkus.datasource.username = xxx
quarkus.datasource.password = xxx

I am using mysql official image with latest tag.

Am I missing something here ? Also if anyone can provide and equal code with reactivex extension would be better. I don't like composite callbacks !

Upvotes: 0

Views: 604

Answers (1)

billyyccc
billyyccc

Reputation: 96

you should not call tx.close() after the commit() since it will schedule a ROLLBACK query, for how to use transaction APIs please take a look at the official documentation.

As for reactiveX extension code you may go to the page, it's in the PostgreSQL client documentation but I think the APIs are the same for MySQL client and I believe it could be improved to be included in the MySQL documentation too.

Moreover I'm not able to reproduce the problem you met, if the problem still exists could you please provide a reproducer and open an issue in https://github.com/eclipse-vertx/vertx-sql-client/issues?

Upvotes: 0

Related Questions